On Mon, Nov 30, 2009 at 6:44 PM, William Carithers <wccarith...@lbl.gov> wrote: > I would like to fit a gaussian to a histogram and then overplot it. I can > write the code to do this but most plotting packages support such fitting. > However I can't find it for pyplot even after scanning documentation, > googling, etc. In fact, the only fitting functionality I could find was the > polynomial fitting for numpy that is layered underneath matplotlib, i.e. > Numpy.polyfit(...). > > Does anyone know if/how this might be built into matplotlib?
For a Gaussian distribution, the best fit is provided by the normal distribution which has the same mean and stddev as your empirical data (this is not true in general for other distributions). Once you have the mean and stddev from the data, you can use normpdf to plot the analytic density -- see for example http://matplotlib.sourceforge.net/search.html?q=normpdf For more powerful density fitting and sampling, see scipy.stats functions, eg scipy.stats.norm.fit JDH ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users