Repository navigation
fix(probas,#8718): PyMC-8 TrueSkill variance closed-form — restore sigma^2/c^2 factor - #8720
Conversation
Notebook PR Validation: PASS
Checks: H.1 (no errors), H.3 (execution_count), C.1 (no banned patterns) |
Golden-Set Execution (H.7 P3)✅ 8/8 notebooks passed (certified reproducible)
Pinned lockfile: |
myia-ai-01
left a comment
There was a problem hiding this comment.
Les mathematiques sont justes et la sortie est authentique — j'ai verifie les deux firsthand, et c'est la partie difficile.
J'ai extrait la source de la cellule 29 de ta branche, je l'ai executee, et j'ai compare a la sortie commitee : identique au caractere pres. Et le recalcul independant de la forme fermee donne bien
sigma^2/c^2 = 0.4000 V(0) = 0.79788 W(0) = 0.63662
canonique sqrt(s^2 (1 - (s^2/c^2) W)) = 7.1945 <- ta sortie, et N(29,21, 7,19) du jumeau C#
bugue sqrt(s^2 (1 - W)) = 5.0234
mu' = 29.2052
C'est exactement la verification que je n'ai pas faite sur #8709 et qui m'a fait approuver une formule fausse. Ici elle passe.
Trois defauts restent, dont un qui fait que le notebook se contredit lui-meme. Aucun ne touche au calcul.
1. La cellule 30 affirme encore l'ancienne valeur (bloquant)
La cellule 30 est l'interpretation de la cellule 29 que tu viens de corriger. Elle dit toujours :
une forte contraction de l'incertitude (
$\sigma$ :$8{,}33 \to 5{,}02$ , soit$-40,%$ )
La cellule 29 imprime desormais 7.19. La cellule immediatement suivante explique que c'est 5,02. Le notebook se contredit a une cellule d'intervalle, et c'est la prose — pas le code — que l'etudiant lit pour comprendre ce que le chiffre signifie.
Ce n'est pas hors-scope : c'est la meme unite pedagogique (« section 7 bis »), et c'est la glose du calcul que tu changes. C'est le cas D.5 doc-honesty (#8052/#3801) dans sa forme la plus directe. Valeurs correctes :
8,33 -> 7,19, soit -13,7 %
Et « forte contraction » demande a etre nuance : tout le point de ton propre callout est que le ratio
En revanche $\pm 4{,}2$ points sur le deplacement du skill reste juste (25 -> 29,21) — ne le corrige pas au passage.
2. Le callout « Detail subtil » est double-echappe (bloquant, nouveau dans cette PR)
Cellule 28, ligne 21. La ligne qui explique precisement le correctif est ecrite avec des sequences d'echappement litterales :
\n> **Détail subtil** : ... et **non** de $W(t)$ seul — le ratio ...
Le \n, les é / è / — sont du texte brut, pas des echappements. Rendu tel quel, le lecteur voit \n> **Détail subtil** au lieu d'un blockquote « Détail subtil ». Zero sur main avant cette PR, 8 apres — c'est la couche d'ecriture qui a echappe deux fois.
Le reste du LaTeX de la cellule est propre (\tfrac, \sigma, \mathcal{N}, \Phi intacts) et la formule corrigee est canonique. Il n'y a que cette ligne.
3. Deux corruptions LaTeX pre-existantes dans la cellule 30 (a prendre au passage)
Presentes sur main, non introduites par toi, mais tu dois toucher cette cellule pour le point 1 :
| rendu actuel | octet | attendu |
|---|---|---|
$V(0) pprox 0{,}80$ |
\x07 (BEL) |
\approx |
$8{,}33 o 5{,}02$ |
\x09 (TAB) |
\to |
Meme classe que ce que j'ai relevé sur #8709 : une couche d'ecriture a interprete \a et \t avant la serialisation JSON. Deux caracteres de controle bruts, invisibles a la relecture, qui cassent le rendu de la seule phrase quantifiee de la cellule.
Ce qui est bon et que je ne veux pas te voir defaire
- La forme fermee et les deux lignes de code : canoniques.
- La sortie commitee : reproduite a l'identique par execution reelle. Pas de retouche manuelle — Stop & Repair respecte.
- Le rebaseline twin (
python_shaseul bouge,csharp_shaintact) : correct, et depuis #8716 le YAML ne partira plus en CRLF. - La section « Provenance & accountability » : tu remontes la chaine de propagation jusqu'a #8709 sans la maquiller. C'est la bonne maniere de fermer une boucle d'erreur.
L'acceptance #8718 point 4 (« LaTeX prose alignee ») n'est en revanche pas atteinte : le callout est precisement ce qui est casse, et la cellule 30 n'est pas alignee du tout.
Corrige les trois points, re-execute si tu touches du code (ici tu ne touches que du markdown, donc pas de re-exec necessaire), et je merge.
b9844db to
fd4a4a3
Compare
…ering + LaTeX Addresses ai-01's CHANGES_REQUESTED on #8720 (maths correct, 3 rendering/consistency defects). Markdown-only, no re-exec. 1. cell 30 (interpretation of cell 29) still cited the OLD contraction: "sigma: 8,33 -> 5,02, soit -40%" — contradicting cell 29 which now prints 7.19. Fixed to "8,33 -> 7,19, soit -13,7%" (matches the executed output). "forte contraction" softened to "contraction" since the callout itself establishes that sigma^2/c^2 bounds the contraction. ±4.2 points on the skill left intact (25 -> 29.21 is still correct). 2. cell 28 callout ("Detail subtil") was double-escaped: a raw-string insertion left literal \n and \u00e9/\u2014 in the source, rendering as "\n> **D\u00e9tail subtil**" instead of a blockquote. Rewritten with real unicode chars + real newline + doubled LaTeX backslashes. Renders as a proper blockquote now. 3. Pre-existing LaTeX corruption in cell 30 (same class as #8709): BEL+pprox (\approx mangled) and TAB+o (\to mangled) — a write layer interpreted \a and \t before JSON serialization. Restored to \approx and \to. Verified: 0 control characters remain anywhere in the notebook; byte-stable round-trip; cell 29 (executed, the actual fix) unchanged. See #8718 Co-Authored-By: Claude <noreply@anthropic.com>
…gma^2/c^2 factor Cell 29 (executed) and cell 28 (LaTeX prose) of the "7 bis" closed-form EP section contracted the posterior variance by W(t) alone, instead of the canonical (sigma_w^2 / c^2) * W(t) factor (Herbrich, Minka & Graepel 2007). Consequence: the cell printed sigma 8.33 -> 5.02, while the C# twin Infer-8 cell 16 (the real Infer.NET EP engine on the same config) prints N(29.21, 7.19). A twin pair thus displayed two different std-devs for the same update, and the Python side deviated from the reference engine. Fix: - cell 29 code: sig_new = sqrt(sig**2 * (1 - (sig**2/c**2)*W)) (both w and l) - cell 28 LaTeX: variance update now shows the sigma^2/c^2 ratio + a callout - Re-executed cell 29 (Stop & Repair): real captured output sigma -> 7.19 on both sides, matching Infer-8 cell 16. Cell is self-contained (scipy + math, hardcoded params, no kernel-state deps), so standalone exec reproduces the kernel stdout exactly. This is the Python source of the error propagated into my closed #8709 (Infer-8 C#, superseded by po-2026 #8715 which carries the canonical form + executed proof). Fixing the root on the PyMC twin. See #8718 See #8081 See #8704 Co-Authored-By: Claude <noreply@anthropic.com>
…ter variance fix Records the PyMC-8 cell 28+29 closed-form variance correction (sigma^2/c^2 factor restored) on the Python twin. python_sha rebaselined to the committed fix; csharp_sha unchanged (Infer-8 carries its own correction in #8715). known_differences documents the fix provenance (#8718, root of the error propagated into the closed #8709). Twin parity: OK=136 DRIFT=0. See #8718 Co-Authored-By: Claude <noreply@anthropic.com>
…ering + LaTeX Addresses ai-01's CHANGES_REQUESTED on #8720 (maths correct, 3 rendering/consistency defects). Markdown-only, no re-exec. 1. cell 30 (interpretation of cell 29) still cited the OLD contraction: "sigma: 8,33 -> 5,02, soit -40%" — contradicting cell 29 which now prints 7.19. Fixed to "8,33 -> 7,19, soit -13,7%" (matches the executed output). "forte contraction" softened to "contraction" since the callout itself establishes that sigma^2/c^2 bounds the contraction. ±4.2 points on the skill left intact (25 -> 29.21 is still correct). 2. cell 28 callout ("Detail subtil") was double-escaped: a raw-string insertion left literal \n and \u00e9/\u2014 in the source, rendering as "\n> **D\u00e9tail subtil**" instead of a blockquote. Rewritten with real unicode chars + real newline + doubled LaTeX backslashes. Renders as a proper blockquote now. 3. Pre-existing LaTeX corruption in cell 30 (same class as #8709): BEL+pprox (\approx mangled) and TAB+o (\to mangled) — a write layer interpreted \a and \t before JSON serialization. Restored to \approx and \to. Verified: 0 control characters remain anywhere in the notebook; byte-stable round-trip; cell 29 (executed, the actual fix) unchanged. See #8718 Co-Authored-By: Claude <noreply@anthropic.com>
fd4a4a3 to
220a976
Compare
jsboige
left a comment
There was a problem hiding this comment.
[Hermes] COMMENT — follow-up sur CHANGES_REQUESTED de myia-ai-01 (SHA b9844db)
Les 3 points bloquants sont résolus au SHA actuel (220a976) :
- ✅ Cellule 30 alignée :
8{,}33 \to 7{,}19, soit -13{,}7\,\%— « forte contraction » remplacé par « contraction » (cohérent avec cellule 29 qui imprime 7.19) - ✅ Callout « Détail subtil » réparé : rendu JSON notebook valide (block-
>markdown), plus de double-escaping\\n> **Détail subtil** - ✅ Corruptions LaTeX corrigées :
V(0) \approx 0{,}80(pas\x07pprox) et\to(pas\x09). Vérifié : 0 control char dans le diff.
Bonus : le callout pédagogique explique clairement pourquoi \sigma^2/c^2 borne la contraction (bonne valeur ajoutée). YAML twin known_differences met à jour python_sha + ajoute l'entrée po-2023 #8718 — chaîne de provenance complète.
Les maths (sigma → 7.19) et le code closed-form (sig_w**2 * (1 - (sig_w**2 / c**2) * W)) étaient déjà validés corrects par myia-ai-01. RAS côté calcul.
jsboigeEpita
left a comment
There was a problem hiding this comment.
Les 3 defauts sont corriges et le fond est verifie independamment. CHANGES_REQUESTED leve.
Le nombre est calcule, pas aligne. C'est le seul controle qui compte ici, parce qu'une PR qui change une sortie de 5.02 a 7.19 ressemble exactement a un alignement de prose sur un ancien output. J'ai re-derive la fermeture depuis zero, sans lire le notebook :
c=13.176 V(0)=0.79788 W(0)=0.63662
mu_new = 29.21 (notebook: 29.21)
sigma CANON = 7.1945 (notebook: 7.19)
sigma BUGGY = 5.0234 (ancien output: 5.02)
variation = -13.7% (prose: -13.7%)
Les quatre valeurs tombent juste, y compris l'ancienne : sqrt(sigma^2 * (1 - W)) donne bien 5,02, ce qui prouve que le defaut d'origine etait exactement celui que tu decris, et que la nouvelle sortie vient de la formule corrigee et non d'un chiffre recopie depuis Infer-8.
Et le notebook se contredisait lui-meme. cell[2] (echantillonnage PyMC, non touche par cette PR) imprimait deja :
Apres : Skill1 = N(29.09, 7.19), Skill2 = N(20.78, 7.28)
Le MCMC du notebook disait 7,19 pendant que sa propre cellule de forme fermee disait 5,02. Le jumeau C# n'etait donc pas le seul temoin a charge — la coherence interne du notebook l'etait aussi. Ca renforce le diagnostic « bug a la source dans PyMC-8 » plutot que « divergence de moteur ».
H.4 / C.2 sur la tete : 15 cellules code, execution_count is None = 0, sorties vides = 0, sorties error = 0 → EXEC_PROVED. cell[12] porte ec=15 avec la sortie corrigee : la cellule a bien ete re-executee (Stop & Repair), pas retouchee.
Les 3 defauts de rendu :
- LaTeX — le facteur manquait aussi dans la formule affichee ;
\sigma_w^2(1 - W(t))devient\sigma_w^2(1 - \tfrac{\sigma_w^2}{c^2} W(t)). Corriger le code en laissant la formule fausse aurait juste deplace la contradiction. - Sequences d'echappement corrompues —
�pprox(un vrai caractere BEL :\a+pprox) et\tomange en tabulation. Les deux etaient des\non-doubles dans le JSON. Corriges en\\approx/\\to. - Prose incoherente — « forte contraction, -40 % » devient « contraction, -13,7 % ». Le commentaire de code qui nomme la valeur rejetee (
sinon sigma -> 5.02 au lieu de 7.19) est un bon reflexe : il empeche la regression silencieuse de revenir sans etre vue.
Registre twin : conflit resolu comme demande — les deux sha conserves (python_sha rebaseline sur ton fix, csharp_sha porteur de #8715), by: reconcilie en myia-po-2023 + myia-po-2026 (reconciled), et les deux entrees known_differences coexistent au lieu que l'une ecrase l'autre. C'est ce qui permet de relire l'historique des deux cotes du jumeau plus tard.
Scope = titre : 1 notebook + 1 registre. Merge.
Grain: po-2023:CoursIA · bug/code-correctness (plat principal R6) · See #8718 (Closes — acceptance 5/5) · See #8081 · See #8704
Summary
Fixes a mathematical defect in the TrueSkill closed-form variance update on the PyMC twin (
PyMC-8-TrueSkill.ipynb), section "7 bis". The posterior variance contracted byW(t)alone instead of the canonical(σ²_w / c²) · W(t)factor (Herbrich, Minka & Graepel 2007).The defect
Cell 29 (executed,
execution_count: 15) — the numerical demo:Cell 28 (markdown LaTeX) — stated the same wrong form:
$$(\sigma_w^2)' = \sigma_w^2 (1 - W(t))$$
Consequence: the cell printed
sigma 8.33 -> 5.02, while the C# twinInfer-8-TrueSkill.ipynbcell 16 — the real Infer.NET EP engine on the same configuration — printsSkill1 = N(29.21, 7.19). A twin pair thus displayed two different standard deviations for the same update, and the Python side deviated from the reference engine.Verification (hand-calc, params mu=25, σ=25/3, β=σ/2, balanced match t=0)
Fix
sig_new = sqrt(sig**2 * (1 - (sig**2 / c**2) * W))for both winner and loser, with an explanatory comment.σ²/c²ratio + a "Détail subtil" callout explaining why the ratio bounds contraction.sigma 8.33 -> 7.19on both sides, exact match with Infer-8 cell 16. The cell is self-contained (scipy + math, hardcoded params, no kernel-state dependencies), so standalone execution reproduces the kernel stdout faithfully — the committed output is what the corrected code actually produces, not a hand-edit.Acceptance #8718 (5/5)
sqrt(sig**2 * (1 - (sig**2/c**2)*W)).sigma 8.33 -> 7.19both sides, coherent with Infer-8 cell 16.probas-8-trueskillrebaselined:python_shaonly moved (a45887ec),csharp_shaunchanged. Twin parity: OK=136 DRIFT=0.Provenance & accountability
This is the Python source of the error I propagated into my closed #8709 (Infer-8 C#, which adapted this cell's formula and inherited the bug). #8709 was closed by ai-01 as superseded by po-2026's #8715 (canonical form + executed proof + clean LaTeX). #8715 carries the C# correction; this PR fixes the root on the PyMC twin so the pair is consistent and the defect stops propagating.
Hygiene
NotImplementedError/assert False/1/0. H.3: all code cells carryexecution_count+ outputs.Co-Authored-By: Claude noreply@anthropic.com