Skip to content

[qr_decomp.md] Update np.random → Generator API#999

Open
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-qr-decomp
Open

[qr_decomp.md] Update np.random → Generator API#999
Chihiro2000GitHub wants to merge 1 commit into
mainfrom
update-rng-qr-decomp

Conversation

@Chihiro2000GitHub

@Chihiro2000GitHub Chihiro2000GitHub commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

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

The four module-level np.random.* calls are replaced with calls on an explicit generator rng = np.random.default_rng(), defined once in the lecture's import cell and reused throughout.

Related PRs and issues

I checked for open PRs and issues related to this lecture. No open PR modifies qr_decomp.md. The one related issue is #582, on seeding lectures with stochastic output — see the note for reviewers below.

Details

  • rng = np.random.default_rng() added to the import cell (import numpy as np / from scipy.linalg import qr).
  • np.random.random(...)rng.random(...) in the QR eigenvalue experiment and in the PCA section's random moments.
  • np.random.multivariate_normal(...)rng.multivariate_normal(...).
  • No fixed seed was introduced, since the lecture did not seed before.
  • No prose changes were needed: the text does not refer to np.random as a module-level function, and the displayed results are eigenvalue comparisons and np.abs(...).max() residuals rather than specific realized draws.
  • The lecture contains no Numba (@jit, @njit, @jitclass, parallel=True, prange) code.
  • A full local build completed successfully and qr_decomp.md executed without errors.

Note for reviewers

This lecture produces stochastic output and has never set a seed, which is the situation tracked in #582. I have kept it unseeded here to stay within the scope of the API migration, but please feel free to add a seed as part of that issue if you would prefer.

Hi @mmcky and @HumphreyYang, I'd be grateful if you could take a look when you have time.

@github-actions

Copy link
Copy Markdown

📖 Netlify Preview Ready!

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

Commit: 541c3bf

📚 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