Commit c0146d3
[mix_model] Update lecture to use JAX (#773)
* [mix_model] Convert code to JAX
Rebased onto main (post #642 style pass). Converts the Numba/NumPy
simulation code to JAX (jax.random keys, jax.lax.scan, jax.vmap),
superseding the interim np.random Generator migration (#978).
Randomness uses explicit jax.random.key threading (keys passed into
simulate / draw_lottery / draw_lottery_MC / simulate_mixed / plot_π_seq
/ π_lim, split where needed) rather than deriving seeds from parameter
values, matching the JAX conversion style guide. draw_lottery_MC uses
jax.scipy.stats.beta.cdf, so the lecture no longer touches NumPy's
legacy RNG. Single seed 42 throughout.
Verified: full lecture (JAX cells + numpyro NUTS MCMC) runs end-to-end
on CPU; MC draws match the target mixture density.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* [mix_model] Style-guide compliance pass
Bring the lecture into full style-guide compliance:
- figures: remove matplotlib titles (ax.set_title), drop hard-coded
figsize, use lw=2 on all line charts, lower-case axis labels
- math: \mathbb{E} / \mathbb{P} for expectation/probability, \mathrm{Beta}
for the distribution name, \log instead of log
- writing: IID (not i.i.d.), Bayes' law (not Bayes' Law / Bayes law)
- doclinks: same-series links use the [](name) auto-title form and drop
the generic 'this quantecon lecture' text
- code: don't pip install jax at the top (GPU admonition covers it),
remove the unused pandas import
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: John Stachurski <john.stachurski@gmail.com>1 parent 2632849 commit c0146d3
1 file changed
Lines changed: 264 additions & 194 deletions
0 commit comments