python - Un-normalized Gaussian curve on histogram -


i have data of gaussian form when plotted histogram. want plot gaussian curve on top of histogram see how data is. using pyplot matplotlib. not want normalize histogram. can normed fit, looking un-normalized fit. here know how it?

thanks! abhinav kumar

as example:

import pylab py import numpy np scipy import optimize  # generate  y = np.random.standard_normal(10000) data = py.hist(y, bins = 100)  # equation gaussian def f(x, a, b, c):     return * py.exp(-(x - b)**2.0 / (2 * c**2))  # generate data bins set of points  x = [0.5 * (data[1][i] + data[1][i+1]) in xrange(len(data[1])-1)] y = data[0]  popt, pcov = optimize.curve_fit(f, x, y)  x_fit = py.linspace(x[0], x[-1], 100) y_fit = f(x_fit, *popt)  plot(x_fit, y_fit, lw=4, color="r") 

enter image description here

this fit gaussian plot distribution, should use pcov give quantitative number how fit is.

a better way determine how data gaussian, or distribution pearson chi-squared test. takes practise understand powerful tool.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -