<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/2169" rel="nofollow">http://projects.scipy.org/numpy/ticket/2169</a> on 2012-06-19 by trac user knopfra, assigned to unknown.</em></p>
<p dir="auto">The array provided in attachment as a pickle file can be used to detect the following issue (64 bit Linux system, python 2.7.3, numpy 1.6.1). The array has 15606478 elements.</p>
<p dir="auto">In [1]: import numpy as np</p>
<p dir="auto">In [2]: a = np.load('data.pkl')</p>
<p dir="auto">In [3]: np.nanmin(a)[[BR]]<br>
Out[3]: 4.715836</p>
<p dir="auto">In [4]: np.nanmax(a)[[BR]]<br>
Out[4]: 4.7189121</p>
<p dir="auto">In [5]: idx = np.where(np.isfinite(a))</p>
<p dir="auto">In [6]: a[idx].mean()[[BR]]<br>
Out[6]: 4.1792714738680736</p>
<p dir="auto">In [7]: from scipy.stats import nanmean</p>
<p dir="auto">In [8]: nanmean(a)[[BR]]<br>
Out[8]: 4.1792714738680727</p>
<p dir="auto">The mean value obtained is clearly wrong.<br>
On a 32 bit system the result is the following:</p>
<p dir="auto">In [1]: import numpy as np</p>
<p dir="auto">In [2]: a = np.load('data.pkl')</p>
<p dir="auto">In [3]: idx = np.where(np.isfinite(a))</p>
<p dir="auto">In [4]: a[idx].mean()[[BR]]<br>
Out[4]: 4.7184738182116019</p>
<p dir="auto">and this time the mean value is correct.</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/2170" rel="nofollow">http://projects.scipy.org/numpy/ticket/2170</a> on 2012-06-19 by trac user knopfra, assigned to unknown.</em></p>
<p dir="auto">The array provided as a pickle file at the following link [http://dl.dropbox.com/u/30592272/data.pkl.gz] can be used to detect the following issue (64 bit Linux system, python 2.7.3, numpy 1.6.1). The array has 15606478 elements.</p>
<p dir="auto">In [1]: import numpy as np</p>
<p dir="auto">In [2]: a = np.load('data.pkl')</p>
<p dir="auto">In [3]: np.nanmin(a)[[BR]]<br>
Out[3]: 4.715836</p>
<p dir="auto">In [4]: np.nanmax(a)[[BR]]<br>
Out[4]: 4.7189121</p>
<p dir="auto">In [5]: idx = np.where(np.isfinite(a))</p>
<p dir="auto">In [6]: a[idx].mean()[[BR]]<br>
Out[6]: 4.1792714738680736</p>
<p dir="auto">In [7]: from scipy.stats import nanmean</p>
<p dir="auto">In [8]: nanmean(a)[[BR]]<br>
Out[8]: 4.1792714738680727</p>
<p dir="auto">The mean value obtained is clearly wrong.<br>
On a 32 bit system the result is the following:</p>
<p dir="auto">In [1]: import numpy as np</p>
<p dir="auto">In [2]: a = np.load('data.pkl')</p>
<p dir="auto">In [3]: idx = np.where(np.isfinite(a))</p>
<p dir="auto">In [4]: a[idx].mean()[[BR]]<br>
Out[4]: 4.7184738182116019</p>
<p dir="auto">and this time the mean value is correct.</p>