[likelihood_ratio_process_2.md] Update np.random → Generator API#991
Open
Chihiro2000GitHub wants to merge 1 commit into
Open
[likelihood_ratio_process_2.md] Update np.random → Generator API#991Chihiro2000GitHub wants to merge 1 commit into
Chihiro2000GitHub wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rs2tDEcDXLnfMnM88v8e1D
56 tasks
📖 Netlify Preview Ready!Preview URL: https://pr-991--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
likelihood_ratio_process_2.mdas part of QuantEcon/meta#299.All
np.random.*draws are replaced with an explicitrng = np.random.default_rng().Related PRs and issues
I checked for open PRs and issues related to this lecture. No open issue concerns it, and the only open PR that touches the file (#651, a
likelihood_bayesstyle-guide PR) changes a single unrelated prose line — nothing overlaps with this migration.Details
rngis defined once in the imports cell and reused in the later main-text cells.lr_ex4,lr_ex5,lr_ex6,lr_ex7) defines its ownrngso the block stays self-contained.np.random.beta(...)→rng.beta(...), andnp.random.rand(N, T)→rng.random((N, T))(note the shape tuple).Numba notes. The two
@jit(parallel=True)functions (compute_posterior_three_models,simulate_three_model_allocation) take pre-generateds_seqarrays as input and do not draw random numbers inside theirprangeloops, so no random draws occur inside the parallel loops.The one jitted draw is in
simulate(@jit), migrated by passingrngin as an explicit argument (w = rng.beta(a, b)). Note thatsimulateis not called anywhere in this lecture, so it is never compiled — the build therefore does not exercise that particular line. Flagging for reviewer judgment.Hi @mmcky and @HumphreyYang, I'd be grateful if you could take a look when you have time.