dimanche 22 août 2021

How to add random state in numpy array

I am creating a random noise using np.random.normal(). I wanted to add random state in it. I tried this:

R = np.random.RandomState(1989)

mu, sigma = 0, 0.1 
noise = R.normal(mu, sigma, [2, 2])

I also tried setting random state using random package:

import random

random.seed(32)
noise = np.random.normal(mu, sigma, [2, 2])

Then I also tried setting random seed with:

np.random.seed(34)

But nothing is working. Can anyone tell me how do I add random state in this noise, so that np.random.normal will give me the same result every time I run it.

NOTE: mu and sigma are mean and standard deviation resp.




Aucun commentaire:

Enregistrer un commentaire