Skip to content

[rand_resp.md] Update np.random → Generator API - #891

Merged
mmcky merged 2 commits into
mainfrom
update-rng-rand-resp
Jul 7, 2026
Merged

mmcky merged 2 commits into
mainfrom
update-rng-rand-resp

Conversation

@Chihiro2000GitHub

Copy link
Copy Markdown
Contributor

Summary

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

Details

  • In MCsimulation, replaced np.random.seed(seed) with rng = np.random.default_rng(seed) to use an explicit local Generator.
  • Replaced all np.random.rand(...) calls with rng.random(...).
  • The existing seed parameter is preserved and passed to default_rng, maintaining the original reproducibility behaviour.
  • No Numba-related code is present in this file.
  • No prose changes were needed.

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 <[email protected]>
@github-actions

github-actions Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

📖 Netlify Preview Ready!

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

Commit: 1d491a8

📚 Changed Lectures


Build Info

@mmcky mmcky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Chihiro2000GitHub, this looks great to me! Clean migration: rng built once per MCsimulation call and reused for all draws, seed preserved, and the np.random.rand(size, n) → rng.random((size, n)) shape-argument translation is correct. No prose references the old API.

@HumphreyYang — could you have a quick pass to confirm before we merge?

@mmcky
mmcky self-requested a review June 16, 2026 23:28

@HumphreyYang HumphreyYang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks @Chihiro2000GitHub and @mmcky, This looks great to me.

@mmcky

mmcky commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

thanks @Chihiro2000GitHub and @HumphreyYang

@mmcky
mmcky merged commit d39b85f into main Jul 7, 2026
1 of 2 checks passed
@mmcky
mmcky deleted the update-rng-rand-resp branch July 7, 2026 00:27
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.

3 participants