Skip to content

Commit 228d317

Browse files
Update rng usage in svd_intro.md (#1003)
1 parent 7f05c34 commit 228d317

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lectures/svd_intro.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ Let's do an example.
280280
import numpy as np
281281
import numpy.linalg as LA
282282
import matplotlib.pyplot as plt
283+
284+
rng = np.random.default_rng()
283285
```
284286
285287
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$.
424426
425427
```{code-cell} ipython3
426428
import numpy as np
427-
X = np.random.rand(5,2)
429+
X = rng.random((5, 2))
428430
U, S, V = np.linalg.svd(X,full_matrices=True) # full SVD
429431
Uhat, Shat, Vhat = np.linalg.svd(X,full_matrices=False) # economy SVD
430432
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
486488
487489
```{code-cell} ipython3
488490
import numpy as np
489-
X = np.random.rand(2,5)
491+
X = rng.random((2, 5))
490492
U, S, V = np.linalg.svd(X,full_matrices=True) # full SVD
491493
Uhat, Shat, Vhat = np.linalg.svd(X,full_matrices=False) # economy SVD
492494
print('U, S, V = ')

0 commit comments

Comments
 (0)