[Python-modules-team] Bug#648034: python-scipy: Gaussian KDE on does not work on integer inputs
Tuure Laurinolli
tuure at laurinolli.net
Tue Nov 8 13:34:19 UTC 2011
Package: python-scipy
Version: 0.7.2+dfsg1-1
Severity: normal
Applying scipy.stats.kde.gaussian_kde to a list of integers, e.g. [1,2,3,4,5], is not same as applying it to a list of floats [1.0, 2.0, 3.0, 4.0, 5.0]. This is quite surprising and should probably be fixed. The output for integers appears to be always 0, although I did not test with very wide range of inputs. This is probably a bug in the internals of gaussian_kde, since it probably converts the input into a NumPy array without specifying the type, and then does math on it expecting it to be an array of floats, whereas it will be an array of some integral type if input is all-integral.
Converting input to floating point types manually allows one to work around this issue.
Expected:
python -c 'import scipy.stats;l=[1,2,3,3,3,3,4,5];k=[1,2,3,4,5];print scipy.stats.kde.gaussian_kde(l)(k) == scipy.stats.kde.gaussian_kde(map(float, l))(k)' to print [True True True True True]
Actual:
python -c 'import scipy.stats;l=[1,2,3,3,3,3,4,5];k=[1,2,3,4,5];print scipy.stats.kde.gaussian_kde(l)(k) == scipy.stats.kde.gaussian_kde(map(float, l))(k)' prints [False False False False False]
-- System Information:
Debian Release: 6.0.2
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-scipy depends on:
ii libamd2.2.0 1:3.4.0-2 approximate minimum degree orderin
ii libblas3gf [libblas.so. 1.2-8 Basic Linear Algebra Reference imp
ii libc6 2.11.2-10 Embedded GNU C Library: Shared lib
ii libgcc1 1:4.4.5-8 GCC support library
ii libgfortran3 4.4.5-8 Runtime library for GNU Fortran ap
ii liblapack3gf [liblapack 3.2.1-8 library of linear algebra routines
ii libstdc++6 4.4.5-8 The GNU Standard C++ Library v3
ii libumfpack5.4.0 1:3.4.0-2 sparse LU factorization library
ii python 2.6.6-3+squeeze6 interactive high-level object-orie
ii python-central 0.6.16+nmu1 register and build utility for Pyt
ii python-numpy 1:1.4.1-5 Numerical Python adds a fast array
Versions of packages python-scipy recommends:
ii g++ [c++-compiler] 4:4.4.5-1 The GNU C++ compiler
ii g++-4.4 [c++-compiler] 4.4.5-8 The GNU C++ compiler
Versions of packages python-scipy suggests:
pn python-profiler <none> (no description available)
-- debconf-show failed
More information about the Python-modules-team
mailing list