Skip to content

[monte_carlo.md] Update np.random → Generator API#741

Open
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-monte-carlo
Open

[monte_carlo.md] Update np.random → Generator API#741
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-monte-carlo

Conversation

@Chihiro2000GitHub
Copy link
Copy Markdown
Contributor

Summary

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

  • Replaced from numpy.random import randn with rng = np.random.default_rng() in the imports block.
  • Replaced all randn(), randn(n), np.random.randn(M), and np.random.randn(2, M) calls with the corresponding Generator API methods (rng.standard_normal()).

Details

rng is 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 and rng was redefined within each solution block. In this lecture, however, the exercise solutions were already not self-contained — they relied on the module-level randn import rather than defining their own random source — so defining rng at 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.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

Deploy Preview for taupe-gaufre-c4e660 ready!

Name Link
🔨 Latest commit 4348139
🔍 Latest deploy log https://app.netlify.com/projects/taupe-gaufre-c4e660/deploys/6a0ac73ec893ec000839f199
😎 Deploy Preview https://deploy-preview-741--taupe-gaufre-c4e660.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

@github-actions github-actions Bot temporarily deployed to pull request May 18, 2026 08:12 Inactive
@github-actions github-actions Bot temporarily deployed to pull request May 18, 2026 08:13 Inactive
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