[os_stochastic.md] Update np.random → Generator API#997
Open
Chihiro2000GitHub wants to merge 1 commit into
Open
[os_stochastic.md] Update np.random → Generator API#997Chihiro2000GitHub wants to merge 1 commit into
Chihiro2000GitHub wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rs2tDEcDXLnfMnM88v8e1D
56 tasks
📖 Netlify Preview Ready!Preview URL: https://pr-997--sunny-cactus-210e3e.netlify.app Commit: 📚 Changed LecturesBuild Info
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates legacy NumPy random API usage in
os_stochastic.mdas part of QuantEcon/meta#299.The seeded
np.random.seed(...)/np.random.randn(...)pattern increate_modelis replaced with an explicit seeded generatorrng = 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
create_model,np.random.seed(seed)+np.random.randn(shock_size)→rng = np.random.default_rng(seed)+rng.standard_normal(shock_size).1234) is kept, since the lecture already seeded for reproducibility.rngis local tocreate_model, so no hidden global random state remains.@jit/prangecode.Note for reviewers
default_rngproduces a different stream from the legacyRandomState, 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.