Reputation: 1
If we have a normal distribution defined by:
mu = 22
sigma = 20
def y(x):
otv = 1/(sigma * np.sqrt(2 * np.pi)) * np.exp( - (x - mu)**2 / (2 * sigma**2))
return otv
x1 = np.arange(0,50)
y1 = y(x1)
How can we use Python to find mu and sigma out of the given set of data (y1, x1)?
Upvotes: 0
Views: 579
Reputation: 11240
numpy.std
gives the standard deviation of an array. numpy.average
gives its average. Both take all sorts of additional arguments.
>> y1.std()
0.00352871767572693
>> y1.mean()
0.0157037359404068
Upvotes: 1