Thu, 10 Sep 2009 13:24:19 -0700, n.l.o wrote:
ehum,then I must have done something wrong. I get the same results doing your example.
But, when I use my data, i.e. a cube of shape (30,512,512) and run the different median I get different answers. Although not with your example data (taking shape to be 10,2,5 or something).
(data at http://magnusp.homeip.net/data0.fits) code:
a = pyfits('data0.fits') a.mean() 90.328727213541669 ndimage.mean(a) 93.617742029825848
weird, or is it just me again?
You have 32-bit single-precision float data, and so numpy.mean uses a 32- bit float accumulator to compute the mean. If you use doubles (64-bit) for the accumulator, you get the same result as ndimage (which also uses double):
a.mean(dtype=np.float64) 93.617742029825848
I think a remark on this should be added to the documentation for mean() and other accumulator methods -- it's sort of a trap for the unwary. -- Pauli Virtanen