[SciPy-User] Trouble with gaussian_kde on uniform integer data, possibly deprecation error

Jacob Biesinger jake.biesinger at gmail.com
Fri May 28 13:03:14 EDT 2010


Oh, great.  Thanks for the workaround.  I opened a ticket for this on Scipy
Trac:  http://projects.scipy.org/scipy/ticket/1181

<http://projects.scipy.org/scipy/ticket/1181>
--
Jake Biesinger
Graduate Student
Xie Lab, UC Irvine
(949) 231-7587


On Fri, May 28, 2010 at 9:46 AM, <josef.pktd at gmail.com> wrote:

> On Fri, May 28, 2010 at 12:30 PM, Jacob Biesinger
> <jake.biesinger at gmail.com> wrote:
> > Hi!
> > Having some trouble with a gaussian_kde on uniform integer data.
> > $ python --version
> > Python 2.6.5
> > $ ipython --Version
> > 0.10
> > $ ipython
> > In [1]: from scipy.stats import gaussian_kde
> > In [2]: import scipy
> > In [3]: randDistFromCenter = map(int, scipy.rand(10000) * 500 - 250)  #
> > should be uniform on [-250,250)
> > In [4]: k = gaussian_kde(randDistFromCenter)
> > /usr/lib/python2.6/dist-packages/scipy/stats/stats.py:1486:
> > DeprecationWarning: scipy.stats.cov is deprecated; please update your
> code
> > to use numpy.cov.
> > Please note that:
> >     - numpy.cov rowvar argument defaults to true, not false
> >     - numpy.cov bias argument defaults to false, not true
> >   """, DeprecationWarning)
> > /usr/lib/python2.6/dist-packages/scipy/stats/stats.py:420:
> > DeprecationWarning: scipy.stats.mean is deprecated; please update your
> code
> > to use numpy.mean.
> > Please note that:
> >     - numpy.mean axis argument defaults to None, not 0
> >     - numpy.mean has a ddof argument to replace bias in a more general
> > manner.
> >       scipy.stats.mean(a, bias=True) can be replaced by numpy.mean(x,
> > axis=0, ddof=1).
> >   axis=0, ddof=1).""", DeprecationWarning)
> > In [5]: x = scipy.linspace(-300,300,100)
> > In [6]: y = k.evaluate(x)
> > In [7]: y
> > Out[7]:
> > array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0,
> >        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0,
> >        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0,
> >        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0,
> >        0, 0, 0, 0, 0, 0, 0, 0])
> >
> > #  Perhaps it's a bandwidth issue, though there should still be at least
> a
> > few non-zero entries!:
> > In [8]: k.covariance
> > Out[8]: array([[ 523.56767608]])
>
>
> kde doesn't like integers, Can you file a ticket for this?
>
> if you don't convert the original sample to integers, or convert them
> to float, e.g
>
> k = gaussian_kde(np.array(randDistFromCenter, float))
>
> then I get y=
> [  2.37718449e-05   4.59333855e-05   8.33629081e-05   1.42283310e-04
>   2.28733649e-04   3.46958715e-04   4.97636815e-04   6.76566775e-04
>   8.74448533e-04   1.07809127e-03   1.27285862e-03   1.44565290e-03
>   1.58750741e-03   1.69501260e-03   1.77025571e-03   1.81947393e-03
> ....
>
> I don't know how good the bandwidth is for a uniform distribution of
> the sample, but you will get a lot of spillover/smoothing at the
> boundary.
>
> Thanks for reporting,
>
> Josef
>
> >
> > --
> > Jake Biesinger
> > Graduate Student
> > Xie Lab, UC Irvine
> > (949) 231-7587
> >
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User at scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
> >
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100528/776c1c05/attachment.html>


More information about the SciPy-User mailing list