[exchangeable] Simplify code and bring lecture into style-guide compliance (#772)
* Update lecture to use JAX and remove numba
* fix typos
* fix typos and add suggestions
* remove prng key
* [exchangeable] Simplify code and bring lecture into style-guide compliance
Following review feedback on #772, drop the JAX conversion rather than
extend it. Per the JAX style guide, the numerical work here runs through
SciPy root finding and quadrature on 100-point plotting grids, so JAX
brought its constraints without its benefits (the jitted section measured
~600x slower than plain NumPy, since quad calls the density scalar by
scalar). Numba is removed as well: the density needs no jit, and the
simulation no longer has a loop to compile.
Changes:
- Split the page-long learning_example helper into create_model plus
three plotting functions, one per panel, so the text can introduce and
discuss each graph in turn (Longye's review suggestion).
- Derive Bayes' Law in odds form and simulate the belief ensemble as a
cumulative product of likelihood ratios, removing the path loop
entirely. This is closer to the mathematics and motivates the
reference to likelihood ratio processes already in the text.
- Use np.random.default_rng with an explicit generator, per the style
guide on NumPy random number generation.
- Replace four `{doc}`this lecture <...>`` links with the auto-title form,
and the hard-coded python-advanced URL with an intersphinx reference.
- Lower-case section headings below the lecture title.
- Fix typos: "less that one", "makes π decrease", "absciassa", "whcih",
"expected_rario", "a sequence is random variables", "about about".
Figures are unchanged in shape and magnitude; the three-panel numbers
(0.524, 0.816, 0.000749) reproduce exactly. Full lecture runs in ~2.6s
versus ~3.4s on main and ~7.8s on the JAX branch.
---------
Co-authored-by: John Stachurski <john.stachurski@gmail.com>
1 file changed
Lines changed: 235 additions & 209 deletions