Repository navigation
Whole lectures: float64 sweeps over seeds for four float32 checks - #20
Conversation
seed_sweeps.py runs hopenhayn, mle_jax and markov_asset_jax's own cells in float64 over seeds, draw counts and iteration counts, with the output in checks/seeds.txt: - hopenhayn's p* has a standard deviation of 3.1% across ten seeds at the lecture's 200 draws, and 1.0% at 2,000; the lecture's seed gives the lowest of the ten. - mle_jax's Newton-Raphson converges from all 20 seeds tried, but jax_factorial overflows past 20!, so log(y!) is 43.67 for every y > 20. - markov_asset_jax's 15-step estimate fails the stability check from 5 of 20 start vectors; from 100 steps every start vector gives the exact 0.9944. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The diagnostic script faithfully reuses the established sibling-check patterns with verified matching kwargs, unpacking, and loops, and its committed output aligns consistently with the README, leaving no outstanding issues.
No open issues 🎉
What changed in this PR
This PR adds a float64 diagnostic sweep as a follow-up to #18, providing evidence for four lecture-jax issues. Where #18 showed that float32 changes hopenhayn, mle_jax, and markov_asset_jax through the random sample (not the arithmetic), this PR quantifies how much each answer moves with the random seed, draw count, or step count within float64 alone. It fits into the lectures/whole/checks/ family of diagnostic scripts that reproduce lecture cells verbatim and vary a single ingredient.
Changes:
- Adds
seed_sweeps.py, which extracts and executes each lecture's own MyST code cells (via the same regex/exec pattern as the sibling checks) and sweeps seeds/draw counts/step counts forhopenhayn,mle_jax,markov_asset_jax, plus ajax_factorialoverflow check. - Adds
seeds.txt, the committed CPU output of that script (M1 Pro, diagnostic run). - Appends one sentence to the README's float32 section summarizing the float64 seed-sensitivity findings, linking to
seeds.txt.
| File | Description |
|---|---|
lectures/whole/checks/seed_sweeps.py |
New diagnostic script sweeping seeds/draws/steps over four lecture checks, reusing the established cell-extraction pattern. |
lectures/whole/checks/seeds.txt |
Committed diagnostic output; numbers (3.1% sd, 5/20 start vectors, 20/20 mle converge) are consistent with the script and README. |
lectures/whole/README.md |
Adds one sentence to the "random sample" bullet summarizing float64 across-seed variability, linking to checks/seeds.txt. |
I verified the script against its sibling scripts and the PR data and found no substantive issues:
create_model(seed=, E_draw_size=, A_draw_size=)kwargs andcompute_p_star(...)[0]unpacking matchhopenhayn_check.py.- Reusing the same
jax.random.keyfor thexandydraws in themleblock is faithful to the lecture (matchesmle_check.py). - The markov
estimateloop replicatesmarkov_asset_check.py's 15-step power iteration exactly. - The README figures and the
checks/seeds.txtrelative link path are correct.
No code comments were warranted.
Review effort: Balanced
A follow-up to #18, as evidence for four lecture-jax issues. #18 found that float32 changes
hopenhayn,mle_jaxandmarkov_asset_jaxthrough the random samplejax.randomdraws, not through the arithmetic. This asks how much each answer moves with the sample in float64 alone, using the lectures' own cells at lecture-jax4b939ec.hopenhaynmle_jaxmle_jaxlog(jax_factorial(y))againstlog(y!)exp(lgamma(y + 1)).astype(int)overflows int64. The printed log-likelihoods are off; the estimates aren't, since the term doesn't depend on βmarkov_asset_jaxIn this PR:
lectures/whole/checks/seed_sweeps.pyand its output,seeds.txt, with one sentence added to the README's float32 section. The runs were on an M1 Pro laptop's CPU, as diagnostic runs.🤖 Generated with Claude Code