Skip to content

[lln_clt.md] Update np.random → Generator API#874

Open
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-lln-clt
Open

[lln_clt.md] Update np.random → Generator API#874
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-lln-clt

Conversation

@Chihiro2000GitHub
Copy link
Copy Markdown

Summary

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

The single legacy call np.random.randint inside gen_x_draws has been replaced with rng.integers from a np.random.default_rng() generator.

Details

rng is introduced as an explicit required argument to gen_x_draws(k, rng), and rng = np.random.default_rng() is defined in the same cell just before the call site. Since rng is always available at the point of use, no rng=None fallback was added.

This differs from the approach taken in a related PR (lecture-python-intro#741), where rng was created once at the top of the lecture and reused across multiple cells — so functions there could be called from contexts where rng was not always explicitly passed, making the if rng is None fallback reasonable. In this lecture, rng is created in the same cell as the function definition and its call site, so the fallback seemed unnecessary.

I'd welcome your thoughts on whether this difference in approach is appropriate, or whether a consistent rng=None pattern should be preferred across lectures.

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>
@github-actions
Copy link
Copy Markdown

📖 Netlify Preview Ready!

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

Commit: 6817071

📚 Changed Lectures


Build Info

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