[SciPy-user] Draw a density line on an histogram
Mon Jan 28 03:07:38 CST 2008
Ok, with gaussian_kde then linspace (it's a bit different than in R).
Is it possible to have a different kernel than "gaussian" ?
> > Hi,
> > I have a series of numbers, and I want to have an idea about their
> > distribution. I start with drawing an histogram with matplotlib.
> > But I would like to have a curve (a "smooth histogram") representing the
> > density (which is not a usual function).
> > Something with kernel density estimates should be possible. Do you have
> > any idea ?
> In : from numpy import *
> In : from scipy.stats import gaussian_kde
> In : d = random.standard_normal(1000)
> In : k = gaussian_kde(d)
> In : d.min(), d.max()
> Out: (-2.7279408369776075, 3.210698358446658)
> In : x = linspace(-3.5, 3.5, 100)
> In : y = k(x)
> Now plot y versus x.
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
More information about the SciPy-user