[Numpy-discussion] bug in numpy.mean() ?
Tue Jan 24 13:01:40 CST 2012
Just what Bruce said.
You can run the following to confirm:
np.mean(data - data.mean())
If for some reason you do not want to convert to float64 you can add the
result of the previous line to the "bad" mean:
bad_mean = data.mean()
good_mean = bad_mean + np.mean(data - bad_mean)
On Tue, Jan 24, 2012 at 12:33 PM, K.-Michael Aye <firstname.lastname@example.org>wrote:
> I know I know, that's pretty outrageous to even suggest, but please
> bear with me, I am stumped as you may be:
> 2-D data file here:
> In : data.mean()
> Out: 3067.0243839999998
> In : data.max()
> Out: 3052.4343
> In : data.shape
> Out: (1000, 1000)
> In : data.min()
> Out: 3040.498
> In : data.dtype
> Out: dtype('float32')
> A mean value calculated per loop over the data gives me 3045.747251076416
> I first thought I still misunderstand how data.mean() works, per axis
> and so on, but did the same with a flattenend version with the same
> Am I really soo tired that I can't see what I am doing wrong here?
> For completion, the data was read by a osgeo.gdal dataset method called
> My numpy.__version__ gives me 1.6.1 and my whole setup is based on
> Enthought's EPD.
> Best regards,
> NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion