[monte_carlo.md] Update np.random → Generator API#741
Open
Chihiro2000GitHub wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <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
monte_carlo.mdas part of QuantEcon/meta#299.from numpy.random import randnwithrng = np.random.default_rng()in the imports block.randn(),randn(n),np.random.randn(M), andnp.random.randn(2, M)calls with the corresponding Generator API methods (rng.standard_normal()).Details
rngis defined once at module level in the imports block and reused throughout the lecture, including in the exercise solution blocks. In previous lectures, exercise solution blocks were typically treated as self-contained andrngwas redefined within each solution block. In this lecture, however, the exercise solutions were already not self-contained — they relied on the module-levelrandnimport rather than defining their own random source — so definingrngat module level and reusing it throughout is the more natural and consistent pattern here.No fixed seed was introduced. No Numba-related code was present.
Hi @mmcky and @HumphreyYang, I'd be grateful if you could take a look when you have time.