[SciPy-user] KDE question

David Cournapeau david@ar.media.kyoto-u.ac...
Sat Nov 10 05:13:31 CST 2007

Gael Varoquaux wrote:
> On Fri, Nov 09, 2007 at 02:34:11PM -0500, Zachary Pincus wrote:
>> I'm using scipy.stats.gaussian_kde to estimate the a probability  
>> density based on some scattered 2D samples. What I would like to do  
>> eventually is plot a line that surrounds (say) 90% of the probability  
>> density.
> If its only plotting you are interested in, matplotlib can do all the
> dirty work for you, using the "contour" command:
> http://matplotlib.sourceforge.net/screenshots/pcolor_demo.py
> which yields:
> http://matplotlib.sourceforge.net/screenshots/pcolor_demo_large.png
I missed this was for plotting. Then the code from the EM toolbox may 
actually be useful, since I used the function mentioned before to plot 
density contours for mixture of Gaussians:


Code there: 
(function density_on_grid: this can be used from a Gaussian mixture 
class, that you may be able use easily from gauss_kde). This may not be 
adapted for your case, since I only coded it with a few Gaussians in 
mind (e.g. I have never tried to do something smart, since I don't need 
mixtures of say 500 Gaussian).



More information about the SciPy-user mailing list