I am trying to add Numpy Random seed to 150 to get the same results.
I tried
simulations = np.random.seed(simulations)
But got me a float error
# Generate sales samples
simulations = 10000
sales_sims = np.random.normal(sales_mean, sales_std, simulations)
print(sales_sims)
print("mean:", np.mean(sales_sims))
print("std:", np.std(sales_sims))
My question: How to set up Numpy random seed to my 10,000 simulations
CodePudding user response:
Here’s a guide on setting the random state for numpy. What does numpy.random.seed(0) do?
np.random.seed(150) #set seed
#Generate sales samples
simulations = 10000
sales_sims = np.random.normal(0, 1, simulations)
print(sales_sims)
print("mean:", np.mean(sales_sims))
print("std:", np.std(sales_sims))
CodePudding user response:
The question is not showing all the details but from what I understand is that you want to make a 10,000 simulations to occur in the same pattern and you want to set seed at 150 as you were told to achieve the same results
So in order to achieve the same results you must set np.random.seed(150)
And keep the simulations as it is as it will be automatically run in the following code sales_sims = np.random.normal(sales_mean, sales_std, simulations)
This show achieve the same results every time. Hope this clarifies how random seed does and how to use it. Cheers