Unseeded RNG re-rolls 10 published figures on every rebuild (heavy_tails, inequality)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- jupyter-notebook, numpy, python
- Domain
- build-system, data-visualization, testing-qa
Research direction
Open heavy_tails.md and inequality.md, then locate the affected default_rng and np.random.randn cells. Replace the unseeded randomness using the suggested seeded-generator approach and rebuild the lectures twice. Done means the affected figures remain byte-identical across builds and the existing lecture output still renders correctly.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Jupyter Notebook
- Stars
- 65
- Forks
- 32
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 6
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from QuantEcon/lecture-python-intro
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
enhancement
Difficulty 2/5 Half a day Newbie friendliness 76/100
QuantEcon/lecture-python-intro#764 · 4 comments ·
All issues in QuantEcon/lecture-python-intro
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
Bug v3
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
package-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oSoWoSo/vOid_Community_repOsitory#147 · 1 comment ·
-
Builders
Difficulty 2/5 1-3 hours Newbie friendliness 72/100