Jan
Jan

Reputation: 1479

How to use np.random.seed() to create new matrix with fixed random value

I want to create new matrix (V) with fixed random value in each position (every time I run algorithm, I want to have this same matrix showing up). Is it possible to use np.random.seed() for matrix? Something like

V = np.zeros([20,50])
V = np.random.seed(V)

Upvotes: 0

Views: 2093

Answers (1)

Julien
Julien

Reputation: 15071

use this to set the seed:

np.random.seed(0) # or whatever value you fancy

and then generate your random data:

V = np.random.rand(your_shape) # or whatever randomness you fancy like randint, randn ...

Upvotes: 4

Related Questions