Skip to content

[os_time_iter.md] Update np.random → Generator API#998

Open
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-os-time-iter
Open

[os_time_iter.md] Update np.random → Generator API#998
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-os-time-iter

Conversation

@Chihiro2000GitHub

@Chihiro2000GitHub Chihiro2000GitHub commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

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

The seeded np.random.seed(...) / np.random.randn(...) pattern in create_model is replaced with an explicit seeded generator rng = np.random.default_rng(seed).

Related PRs and issues

I checked for open PRs and issues related to this lecture. No open PR touches it and no open issue concerns this migration.

Details

  • In create_model, np.random.seed(seed) + np.random.randn(shock_size)rng = np.random.default_rng(seed) + rng.standard_normal(shock_size).
  • The existing fixed seed (1234) is kept, since the lecture already seeded for reproducibility. rng is local to create_model, so no hidden global random state remains.
  • The lecture has no @jit/prange code.

Note for reviewers

default_rng produces a different stream from the legacy RandomState, so the same seed gives different draws. The figures are unchanged; only the printed numbers shift slightly.

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

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rs2tDEcDXLnfMnM88v8e1D
@github-actions

Copy link
Copy Markdown

📖 Netlify Preview Ready!

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

Commit: e6cd2e4

📚 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