From ace44f022931a3cb855fc3ac7a2ff5be15c0afe1 Mon Sep 17 00:00:00 2001 From: Chihiro Watanabe Date: Sun, 26 Jul 2026 13:21:06 +0900 Subject: [PATCH] Update rng usage in svd_intro.md --- lectures/svd_intro.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lectures/svd_intro.md b/lectures/svd_intro.md index bf1d8fca8..daae7edc6 100644 --- a/lectures/svd_intro.md +++ b/lectures/svd_intro.md @@ -280,6 +280,8 @@ Let's do an example. import numpy as np import numpy.linalg as LA import matplotlib.pyplot as plt + +rng = np.random.default_rng() ``` Having imported these modules, let's do the example. @@ -424,7 +426,7 @@ First, let's study a case in which $m = 5 > n = 2$. ```{code-cell} ipython3 import numpy as np -X = np.random.rand(5,2) +X = rng.random((5, 2)) U, S, V = np.linalg.svd(X,full_matrices=True) # full SVD Uhat, Shat, Vhat = np.linalg.svd(X,full_matrices=False) # economy SVD print('U, S, V =') @@ -486,7 +488,7 @@ To illustrate this case, we'll set $m = 2 < 5 = n $ and compute both full and r ```{code-cell} ipython3 import numpy as np -X = np.random.rand(2,5) +X = rng.random((2, 5)) U, S, V = np.linalg.svd(X,full_matrices=True) # full SVD Uhat, Shat, Vhat = np.linalg.svd(X,full_matrices=False) # economy SVD print('U, S, V = ')