Skip to content

[theil_2.md] Update np.random → Generator API#1005

Open
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-theil-2
Open

[theil_2.md] Update np.random → Generator API#1005
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-theil-2

Conversation

@Chihiro2000GitHub

Copy link
Copy Markdown
Contributor

Summary

This PR migrates legacy NumPy random API usage in theil_2.md as part of QuantEcon/meta#299.

The seeded np.random.seed(...) / np.random.randn(...) pattern in the cell that plots standard against robust consumption paths is replaced with an explicit seeded generator rng = np.random.default_rng(0).

Related PRs and issues

I checked for open PRs and issues related to this lecture. No open PR modifies theil_2.md. Issue #990 lists theil_2.md among the lectures with dangling citation keys, but the fix there is to quant-econ.bib rather than to this file, and this PR does not attempt to address it.

Details

  • np.random.seed(0)rng = np.random.default_rng(0), and np.random.randn(T_sim - 1)rng.standard_normal(T_sim - 1).
  • The existing seed (0) is kept, and rng is local to the cell that uses it, so no hidden global random state remains.
  • Both panels of the figure continue to share the same shock_path, so the comparison between the standard and robust policies is unaffected.
  • No prose changes were needed: the text does not refer to np.random, and it describes the paths qualitatively rather than by their realized values.
  • The lecture contains no Numba (@jit, @njit, @jitclass, parallel=True, prange) code.
  • A full local build completed successfully and theil_2.md executed without errors.

Note for reviewers

The figure changes: default_rng draws from a different stream than the legacy API, so the same seed gives different draws. The rebuilt figure shows the same pattern as the current one.

Hi @mmcky and @HumphreyYang, I'd be grateful if you could take a look when you have time.

@github-actions

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-1005--sunny-cactus-210e3e.netlify.app

Commit: e2dee3d

📚 Changed Lectures


Build Info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant