Skip to content Skip to sidebar Skip to footer

Python Numpy.random.normal

I generated random 20 numbers with mean 0 and variance 1 (np.random.normal). I calculated the variance twice ddof = 1 and 0. My question is i am trying to add (mean 0 and variance

Solution 1:

the definition: variance = (standard deviation)^2, then standard deviation = sqrt(variance), in consequence:

import numpy as np

mean = 0, 
variance = 1,
np.random.normal(loc = mean, scale= np.sqrt(variance), 20)

#caluclateing the unbiased_estimator and the biased_estimator
unbiased_estimator = np.var(x, ddof=1)
biased_estimator = np.var(x, ddof=0)


print ("Unbiased_estimator : ",unbiased_estimator)
print ("Biased_estimator   : ", biased_estimator)

Output:

Unbiased_estimator :1.08318083742Biased_estimator   :1.02902179555

Post a Comment for "Python Numpy.random.normal"