[SciPy-user] bug and fix in Scipy.Scientific.Statistics.Histogram
danny_shevitz at yahoo.com
Wed Jun 23 12:59:00 CDT 2004
I found a bug in the histogram code written by Konrad Hinsen . The
existing version of the code is Scipy.Scientific.Statistics.Histogram
histo = N.add.reduce(N.equal(N.arange(nbins)[:,N.NewAxis], data), -1)
The correct code should be:
histo = N.add.reduce(N.equal(N.arange(nbins)[:,N.NewAxis],
The difference is the .astype(N.Int) after the N.equal block. The bug
manifests itself whenever bin counts get above 256, the counts cycle
back to 0. Logicals in Numeric are short ints and the above change
turns them back into regular ints. Allegedly counting on logicals as
0's or 1's is fraught with peril, and this code runs afoul of it.
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
More information about the SciPy-user