GitHub

@@ -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

```

284286285287

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$.

424426425427

```{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

486488487489

```{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 = ')

Read the original on github.com ↗