[ar1_processes.md] Update np.random → Generator API#794
Open
Chihiro2000GitHub wants to merge 1 commit into
Open
[ar1_processes.md] Update np.random → Generator API#794Chihiro2000GitHub 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>
✅ Deploy Preview for taupe-gaufre-c4e660 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
40 tasks
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
ar1_processes.mdas part of QuantEcon/meta#299.Details
The two migrated calls both appear in exercise solution blocks (the main text has no random draws). Each solution block defines its own
rngvianp.random.default_rng()and remains self-contained.ar1p_ex1solution (@njitfunction):np.random.randn()→rng.standard_normal(). Since Numba cannot construct aGeneratorinside a jitted function,rngis passed in as an argument. The original implementation re-seeded withnp.random.seed(1234)on every call tosample_moments_ar1, so a freshrng = np.random.default_rng(1234)is created for eachkin the calling loop to match that behaviour.ar1p_ex3solution:np.random.randn(n)→rng.standard_normal(n), with no fixed seed (as in the original).Hi @mmcky and @HumphreyYang, I'd be grateful if you could take a look when you have time.