Skip to content

Unseeded RNG re-rolls 10 published figures on every rebuild (heavy_tails, inequality) #833

Description

@mmcky

Found during the independent validation tracked in QuantEcon/workspace-lectures#36, which required proving that the 2026-08-11 dataset repoint (#832) changed no figure pixels on the published site.

What was measured

Every image referenced by heavy_tails.html, mle.html and inequality.html was compared byte-for-byte between the build-publish artifacts of publish-2026aug07 (run 31133959513) and publish-2026aug11 (run 31462325438), with the live site verified identical to the aug11 artifact.

The repoint itself is clean: mle 8/8 identical, and every dataset-driven figure is byte-identical — firm-size, city-size, GDP-per-capita, CCDF empirics, and all six SCF-driven inequality figures. The wealth-distribution figure differs only by ±1 in channel value on 0.02% of pixels (anti-aliasing rounding; its input CSV is byte-identical across the old and new hosts and the fitted slopes are identical).

The finding

10 figures differ materially between the two builds, and every one traces to an unseeded RNG cell: heavy_tails hist-obs, hist-obs2 and hist-normal-btc (rng = np.random.default_rng() with no seed), and seven inequality simulation and exercise-solution figures (np.exp(np.random.randn(n)) and downstream Lorenz/Gini plots).

Because jupyter-cache invalidates per notebook, any edit to these lectures re-executes the whole notebook and re-rolls this entire class of figures — the repoint merely triggered a rebuild. Published figures are therefore not reproducible run-to-run, and pixel-level regression checking (the thing the validation needed) is defeated by noise.

Suggested fix

Seed the generators in the affected cells (np.random.default_rng(seed), and replace the bare np.random.randn calls with a seeded generator, which is also the style-guide-preferred API). A one-pass sweep over heavy_tails.md and inequality.md eliminates the churn permanently.

To be clear: this is not a regression of the repoint — it is a pre-existing property of the two lectures that the validation surfaced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions