[lln_clt.md] Update np.random → Generator API#874
Open
Chihiro2000GitHub wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 tasks
📖 Netlify Preview Ready!Preview URL: https://pr-874--sunny-cactus-210e3e.netlify.app Commit: 📚 Changed LecturesBuild Info
|
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
lln_clt.mdas part of QuantEcon/meta#299.The single legacy call
np.random.randintinsidegen_x_drawshas been replaced withrng.integersfrom anp.random.default_rng()generator.Details
rngis introduced as an explicit required argument togen_x_draws(k, rng), andrng = np.random.default_rng()is defined in the same cell just before the call site. Sincerngis always available at the point of use, norng=Nonefallback was added.This differs from the approach taken in a related PR (lecture-python-intro#741), where
rngwas created once at the top of the lecture and reused across multiple cells — so functions there could be called from contexts whererngwas not always explicitly passed, making theif rng is Nonefallback reasonable. In this lecture,rngis 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=Nonepattern should be preferred across lectures.Hi @mmcky and @HumphreyYang, I'd be grateful if you could take a look when you have time.