[SciPy-user] scipy.stats.gaussian_kde broken?

Zachary Pincus zpincus at stanford.edu
Tue Mar 28 19:03:54 CST 2006


Never mind. This was due to a bug in numpy.dot() which is fixed in  
the newest version.

Zach


On Mar 28, 2006, at 4:33 PM, Zachary Pincus wrote:

> Hi folks,
>
> I can't seem to get scipy.stats.gaussian_kde to work properly. Here
> is an example.
>
> [In:] scipy.__version__
> '0.4.9.1754'
> [In: ] numpy.__version__
> '0.9.7.2262'
> [In:] k = scipy.stats.gaussian_kde([-2, -1, -0.5, 0, 0, 0, 0, 0.5, 1,
> 2])
> [In:] k([-100, -2, 0, 2, 100])
> array([ 0.52684053,  0.58537837,  0.52762998,  0.52684053,   
> 0.52684053])
>
> Clearly the above result is wrong. The 'dataset' points cluster
> around zero, and have no support anywhere near 100 or -100. Yet the
> estimated density is essentially flat across that whole range.
>
> Even more strange is the fact that when the size of the set of points
> to estimate the density at is larger than the size of the data, the
> first estimated value is different than the others.
> [In:] k([-2])
> array([ 0.58537837])
> [In:] k([-2] * 7)
> array([ 0.58537837,  0.58537837,  0.58537837,  0.58537837,   
> 0.58537837,
>          0.58537837,  0.58537837])
> [In:] k([-2] * 10)
> array([ 0.08691171,  0.58537837,  0.58537837,  0.58537837,   
> 0.58537837,
>          0.58537837,  0.58537837,  0.58537837,  0.58537837,
> 0.58537837])
>
> In fact, I suspect that this first estimated value is the correct
> value, and the rest are garbage.
>
> Any thoughts?
>
> Zach Pincus
> Program in Biomedical Informatics and Department of Biochemistry
> Stanford University School of Medicine
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user



More information about the SciPy-user mailing list