Skip to content

feat(kelly,#19516): Fractional Kelly companion -- surface croissance/variance multi-seed - #19529

Merged
jsboige merged 2 commits into
mainfrom
fix/19516-fractional-kelly
Oct 7, 2026
Merged

jsboige merged 2 commits into
mainfrom
fix/19516-fractional-kelly

Conversation

@jsboige

@jsboige jsboige commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Grain: DEEP/notebook-python — lane myia-po-2024:CoursIA-2 — prev: LIGHT/refactor #19500

Sujet

Carnet compagnon du lake kelly_lean (plan #16231, issue #19516) qui mesure le compromis croissance / variance du fractional Kelly. Pour c ∈ [0, 2], sweep multi-seed Monte-Carlo (T = 2000 pas, 8 seeds parmi {0, 1, 7, 42, 99, 123, 456, 789}) de la log-croissance finale et de son écart-type.

Repère canonique

p = 0.55, b = 1 (binaire no-vig), f* = (b·p − q)/b = 0.10, g(f*) = 0.005008 au log-croissance.

c g(c·f*) théo std(log W) théo % du pic g % du std max écart MC vs théo (log-W)
0.25 0.00219 1.11 44 % 25 % 5.6 %
0.50 0.00375 2.23 75 % 50 % 6.5 %
0.75 0.00469 3.34 94 % 75 % 7.8 %
1.00 0.00501 4.47 100 % 100 % 9.8 %
1.25 0.00469 5.59 94 % 125 % 13.1 %
1.50 0.00374 6.73 75 % 151 % 19.7 %

Lecture

  • Demi-Kelly (c = 0.5) : 75 % de la log-croissance pour 50 % de l'écart-type — compromis croissance/variance de 1.5:1 qui rend la fraction attractive en production (cf. Thorp, The Kelly Criterion in Blackjack, Sports Betting, and the Stock Market).
  • Au-delà de c = 1 : zone over-bet (variance explose linéairement, log-croissance décroît). c = 1 est bien l'unique maximum de g.
  • 8 seeds suffisent pour la zone praticienne (c ∈ [0, 1.25], écart MC vs théorie ~5–10 %). Au-delà, T plus grand (~10⁴) serait nécessaire pour stabiliser les queues.

Acceptance #19516 (carnet 1)

  • Companion Python : carnet créé Kelly_companion-Fractional-Python.ipynb, exécuté via nbclient (Tell c.18529 voie 1), 7 cellules code avec execution_count = 1..7, 0 erreur, 0 cellule NotImplementedError (C.1 conforme).
  • Sorties multi-seed : 8 seeds, surface croissance/variance mesurée, figure fractional_kelly_tradeoff.png (139 KB) embarquée + sauvegardée.
  • Lake Fractional.lean : à venir c.56 — module Fractional avec preuve directe growth(c·f*) ≤ growth(f*) par monotonicité du log (pas d'invocation de concavité abstraite, suivant la stratégie contournée documentée en Growth.lean:22).
  • Renommage : Kelly_companion-Fractional-Python.ipynb utilise le naming canonical post-rename(kelly,#16231): suffixes kernel des compagnons + section Carnets suivants #19518 (qui rebascule la convention Kelly_companion.ipynb → Kelly_companion-Python.ipynb). Cohérent avec le merge à venir de rename(kelly,#16231): suffixes kernel des compagnons + section Carnets suivants #19518.

C.2 — outputs

  • 7 cellules code, toutes avec execution_count non-null et outputs non-vides (sauf cellule 1 = import qui n'a pas d'output par construction).
  • Figure PNG embarquée en cellule 12 (display_data, 139 444 bytes) + sauvegardée à côté du carnet.
  • Diff +507/−0 (2 fichiers créés) : notebook 14 cellules, PNG 139 KB.

Validation locale

  • python scripts/notebook_tools/validate_pr_notebooks.py origin/main ... : 1/1 PASS (8 code cells, 0 erreur).
  • compile() au head : cellule 5 (growth + sweep), cellule 7 (std_logW_per_step), cellule 10 (MC sweep) — toutes valides, 0 erreur.
  • H.3 pre-commit : execution_count non-null sur toutes les cellules code.
  • C.1 : grep raise NotImplementedError\|assert False\|1/0 sur le notebook → 0 hit.

Refs #19516, #16231.

🤖 Generated with Claude Code

…variance multi-seed

Carnet compagnon du lake kelly_lean (plan #16231) qui mesure le
compromis croissance / variance du *fractional Kelly* : pour c in [0, 2],
sweep multi-seed Monte-Carlo (T=2000 pas, n_seeds=8 parmi
{0, 1, 7, 42, 99, 123, 456, 789}) de la log-croissance finale et de
son ecart-type.

Repere canonique : p=0.55, b=1, f* = 0.10, g(f*) = 0.005008.
- demi-Kelly (c=0.5) : g=0.00375 (75% du pic), std=2.23 (50% du std max)
  -> compromis croissance/variance de 1.5:1
- 8 seeds, ecart MC vs theorie ~5-10% sur la zone praticienne c in [0, 1.25]

Carnet 1 (Fractional Kelly) de l'acceptance #19516 partiellement couvert :
- companion Python execute avec sorties multi-seed (acceptance explicite)
- lake Fractional (growth(c·f*) ≤ growth(f*)) a venir c.56 via module
  Fractional.lean -- preuve directe par monotonicite du log, pas de
  concavite requise (cf. commentaire Growth.lean:22 sur la strategie
  contournee pour le phare kelly_optimal).

Co-Authored-By: Claude Haiku 4.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Notebook outputs-required (H.4 schema): PASS (every code cell carries an outputs: list)

@github-actions github-actions Bot added the variation-tag-missing PR sans tag Grain: <TIER>/<GENRE> (variation-protocol) label Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

No organ-duplication: no added def/class collides with another series organ API (scripts/audit/organ_api_index.yaml).

Detector: python scripts/audit/detect_organ_duplication.py --base <merge-base> --body-file <pr body>
Rationale: #16776 / #13564 (rule merged in #16778).

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Grain tag obligatoire (#10045, bloquant).

Grain tag absent (no Grain: / in body).

Pour passer ce gate, le body doit porter en tete une ligne de la forme :

Grain: <DEEP|MED|LIGHT>/<genre> -- lane <machine:workspace> -- prev: <TIER>/<GENRE> #<PR>

Le <genre> doit figurer dans l'enumeration §1 de variation-protocol.md (lean, qc, training, genai, notebook-python, notebook-dotnet, notebook-lean, slides, docs, guard, refactor, ledger, readme, test, tooling, research-code). Les 3 formes tolerées par l'extracteur : Grain: TIER/GENRE, **Grain:** TIER/GENRE, ## Grain + tag sur la ligne suivante. La lane doit suivre le format <machine>:<workspace> (cf. lane-claim-protocol.md).

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✅ No prose/output mismatch detected in the notebooks this PR changed.

Scope = notebooks CHANGED in this PR, not the whole corpus. Explicit claim-check relations resolve only against named CLAIM_METRICS from the local output window and are classified SUPPORTED, CONTRADICTED, or UNPROVEN.
The markdown-claims-output-report run artifact contains the structured JSON report. See python scripts/check_markdown_claims_output.py --help for re-running locally.
Detector rationale: c.290 / c.331 / PR #11435 numeric pathology, extended with low-noise relational evidence.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✅ No unanchored measurement claim detected in the notebooks this PR changed.

Scope = notebooks CHANGED in this PR, not the whole corpus. The stale-claim-report run artifact holds the structured JSON.
Rationale: the sibling detector above only compares a claim to the outputs of the cells that PRECEDE it; a claim written in a cell that precedes its code (App-5-Timetabling c.2/c.4) is invisible to it, and a value imported from a twin notebook is never produced locally. See python scripts/check_stale_claims.py --help.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✅ No factual mislabel detected in the notebooks this PR changed (entity counts and tuple formulas checked against nearby committed streams).

Scope = notebooks CHANGED in this PR, not the whole corpus. The factual-mislabel-report run artifact holds the structured JSON.
Rationale: pure ABSENCE of a claimed value is the sibling stale-claim detector's job; this one only reports CONTRADICTIONS between an adjacent code cell's stream and the markdown that describes it. See python scripts/check_factual_mislabel.py --help.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Golden-Set Execution (H.7 P3)

✅ 9/9 notebooks passed (certified reproducible)

Notebook Status Time
2.1-Workflow-ML.ipynb ✅ SUCCESS 6.2s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 5.3s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 6.2s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 6.0s
Search-01-StateSpace.ipynb ✅ SUCCESS 4.5s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 0.8s
RL-04-Bandits-Manchots-Python.ipynb ✅ SUCCESS 17.3s
GameTheory-04c-NashExistence-Python.ipynb ✅ SUCCESS 3.4s
GameTheory-13d-Optimistic-CFR-Python.ipynb ✅ SUCCESS 8.7s

Pinned lockfile: scripts/notebook_tools/golden_set.lock.txt (H.7 P3, axe A #4208)

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Notebook PR Validation: PASS

  • Notebooks checked: 1
  • Code cells validated: 7
  • Result: All passed

Checks: H.1 (no errors), H.3 (execution_count), C.1 (no banned patterns)
Non-Python kernels (.NET/Lean): C.1 + errors only (execution_count advisory)
QuantConnect notebooks: C.1 + errors only (require QC Cloud for execution)

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Path-collision (organ #13359/#13615)

Cette PR #19529 (feat(kelly,#19516): Fractional Kelly companion -- surface croissance/variance multi-seed) touche au moins un chemin de fichier aussi modifie par d'autres PRs ouvertes. Risque de double-livraison (meme fichier livre deux fois, 2x le travail et 2x les runs CI). Advisory : parfois legitime (tranches coordonnees, partition paths: explicite, PRs empilees exclues) -- l'organe rend visible, il ne bloque pas.

@github-actions github-actions Bot added the pr-overlap Advisory: another open PR touches the same files (organ #13615) label Oct 6, 2026
jsboige added a commit that referenced this pull request Oct 6, 2026
…lti-seed (carnet 2)

Carnet compagnon Python du lake `kelly_lean` (issue #19516 carnet 2, plan
#16231). Mesure le biais de l'optimiste : quand `p` est estime avec
`p_hat ~ N(p, sigma)`, la fraction de Kelly `kellyFrac(p_hat)` surexpose
le capital. La perte de croissance depend fortement de sigma, ce qui
justifie quantitativement le *shrinkage* (fraction c < 1).

Repere canonique : p = 0.55, b = 1 (binaire no-vig), f* = 0.10, g(f*) =
0.005008. 5 niveaux sigma (0, 0.01, 0.025, 0.05, 0.10), T = 2000 pas, 8
seeds parmi {0, 1, 7, 42, 99, 123, 456, 789} (C.3 multi-seed).

Mesures :
- sigma = 0.000 : <logW>/T = 0.004519 (90.23 % de g*, bruit MC)
- sigma = 0.010 : 0.004320 (86.26 %, perte negligeable)
- sigma = 0.025 : 0.003788 (75.64 %)
- sigma = 0.050 : 0.002277 (45.46 %, shrinkage 0.5-0.8 rentable)
- sigma = 0.100 : -0.003163 (-63.16 %, abandon ou c < 0.5)

Acceptance #19516 carnet 2 : notebook execute via nbclient (Tell c.18529
voie 1), 5 cellules code avec execution_count = 1..5, 0 erreur, 0
cellule NotImplementedError (C.1). Sorties multi-seed chiffrees, figure
optimist_bias_loss.png embarquee + sauvegardee, justification
quantitative du shrinkage. Lie au lake Fractional.lean (c.56, PR #19534)
et au companion Fractional carnet 1 (PR #19529).

Refs #19516 (carnet 2), #16231.

Co-Authored-By: Claude Haiku 4.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot removed the variation-tag-missing PR sans tag Grain: <TIER>/<GENRE> (variation-protocol) label Oct 7, 2026
@jsboige
jsboige merged commit b46f1f6 into main Oct 7, 2026
95 of 97 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consecutive-code-cells Modified notebook has >=2 consecutive code cells (#12797) pr-overlap Advisory: another open PR touches the same files (organ #13615)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant