Re: [Numpy-discussion] numpy.histogram not giving expected results

2014-07-02 Thread Julian Taylor
On 02.07.2014 20:04, Chris Barker wrote: > On Wed, Jul 2, 2014 at 10:36 AM, Julian Taylor > mailto:jtaylor.deb...@googlemail.com>> > wrote: > > we recently fixed a float32/float64 issue in histogram. > https://github.com/numpy/numpy/issues/4799 > > > It's a good idea to keep the edges in

Re: [Numpy-discussion] numpy.histogram not giving expected results

2014-07-02 Thread Chris Barker
On Wed, Jul 2, 2014 at 10:36 AM, Julian Taylor < jtaylor.deb...@googlemail.com> wrote: we recently fixed a float32/float64 issue in histogram. > https://github.com/numpy/numpy/issues/4799 It's a good idea to keep the edges in the same dtype as the input data, it will make for fewer surprises, bu

Re: [Numpy-discussion] numpy.histogram not giving expected results

2014-07-02 Thread Julian Taylor
On 02.07.2014 19:29, Chris Barker wrote: > On Wed, Jul 2, 2014 at 7:57 AM, Mark Szepieniec > wrote: > > Looks this could be a float32 vs float64 problem: > > > that would explain it. > > > I guess users always be very careful when mixing floating point >

Re: [Numpy-discussion] numpy.histogram not giving expected results

2014-07-02 Thread Chris Barker
On Wed, Jul 2, 2014 at 7:57 AM, Mark Szepieniec wrote: > Looks this could be a float32 vs float64 problem: > that would explain it. > I guess users always be very careful when mixing floating point types, but > should numpy prevent (or warn) the user from doing so in this case? > I don't thin

Re: [Numpy-discussion] numpy.histogram not giving expected results

2014-07-02 Thread Mark Szepieniec
Looks this could be a float32 vs float64 problem: In [19]: data32 = np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.05, -0.05], dtype=np.float32) In [20]: data64 = np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.05, -0.05], dtype=np.float64) In [21]: bins32 = np.arange(-0.1, 0.101, 0.05, d

Re: [Numpy-discussion] numpy.histogram not giving expected results

2014-07-02 Thread Mark Szepieniec
Hi Catherine, I can't reproduce your issue with bins_list vs. bins_arange, but passing both range and number of bins to np.histogram does give the same strange behavior for me: In [16]: data = np.array([ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0.05, -0.05]) I

Re: [Numpy-discussion] numpy.histogram not giving expected results

2014-07-01 Thread Chris Barker
A few thoughts: 1) don't use arange() for flaoting point numbers, use linspace(). 2) histogram1d is a floating point function, and you shouldn't expect exact results for floating point -- in particular, values exactly at the bin boundaries are likely to be "uncertain" -- not quite the right word,

[Numpy-discussion] numpy.histogram not giving expected results

2014-07-01 Thread Moroney, Catherine M (398D)
Hello, I'm trying to calculate a 1-d histogram of a distribution that contains mostly zeros, and I'm having problems with examples where the values to be histogrammed fall exactly on the bin boundaries: For example, this gives me the expected results (entering the exact bin values): >>> data ar