Skip to content

Commit 541c3bf

Browse files
Update rng usage in qr_decomp.md
1 parent 370a58f commit 541c3bf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

lectures/qr_decomp.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ Now let's write some homemade Python code to implement a QR decomposition by dep
169169
```{code-cell} ipython3
170170
import numpy as np
171171
from scipy.linalg import qr
172+
173+
rng = np.random.default_rng()
172174
```
173175

174176
```{code-cell} ipython3
@@ -354,7 +356,7 @@ Here goes
354356

355357
```{code-cell} ipython3
356358
# experiment this with one random A matrix
357-
A = np.random.random((3, 3))
359+
A = rng.random((3, 3))
358360
```
359361

360362
```{code-cell} ipython3
@@ -396,14 +398,14 @@ k = 5
396398
n = 1000
397399
398400
# generate some random moments
399-
𝜇 = np.random.random(size=k)
400-
C = np.random.random((k, k))
401+
𝜇 = rng.random(size=k)
402+
C = rng.random((k, k))
401403
Σ = C.T @ C
402404
```
403405

404406
```{code-cell} ipython3
405407
# X is random matrix where each column follows multivariate normal dist.
406-
X = np.random.multivariate_normal(𝜇, Σ, size=n)
408+
X = rng.multivariate_normal(𝜇, Σ, size=n)
407409
```
408410

409411
```{code-cell} ipython3

0 commit comments

Comments
 (0)