[Numpy-discussion] bug in numpy.mean() ?

Kathleen M Tacina Kathleen.M.Tacina@nasa....
Tue Jan 24 17:21:35 CST 2012


I found something similar, with a very simple example.

On 64-bit linux, python 2.7.2, numpy development version:

In [22]: a = 4000*np.ones((1024,1024),dtype=np.float32)

In [23]: a.mean()
Out[23]: 4034.16357421875

In [24]: np.version.full_version
Out[24]: '2.0.0.dev-55472ca'


But, a Windows XP machine running python 2.7.2 with numpy 1.6.1 gives:
>>>a = np.ones((1024,1024),dtype=np.float32)
>>>a.mean()
4000.0
>>>np.version.full_version
'1.6.1'


On Tue, 2012-01-24 at 17:12 -0600, eat wrote:

> Hi,
> 
> 
> 
> Oddly, but numpy 1.6 seems to behave more consistent manner:
> 
> 
> In []: sys.version
> Out[]: '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
> (Intel)]'
> In []: np.version.version
> Out[]: '1.6.0'
> 
> 
> In []: d= np.load('data.npy')
> In []: d.dtype
> Out[]: dtype('float32')
> 
> 
> In []: d.mean()
> Out[]: 3045.7471999999998
> In []: d.mean(dtype= np.float32)
> Out[]: 3045.7471999999998
> In []: d.mean(dtype= np.float64)
> Out[]: 3045.747251076416
> In []: (d- d.min()).mean()+ d.min()
> Out[]: 3045.7472508750002
> In []: d.mean(axis= 0).mean()
> Out[]: 3045.7472499999999
> In []: d.mean(axis= 1).mean()
> Out[]: 3045.7472499999999
> 
> 
> Or does the results of calculations depend more on the platform?
> 
> 
> 
> 
> My 2 cents,
> eat

-- 
--------------------------------------------------
Kathleen M. Tacina
NASA Glenn Research Center
MS 5-10
21000 Brookpark Road
Cleveland, OH 44135
Telephone: (216) 433-6660
Fax: (216) 433-5802
--------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120124/5cc422b3/attachment.html 


More information about the NumPy-Discussion mailing list