[Numpy-discussion] Medians that ignore values

Pierre GM pgmdevlist@gmail....
Thu Sep 18 13:23:25 CDT 2008


On Thursday 18 September 2008 13:31:18 Peter Saffrey wrote:
> The version in the Ubuntu package repository. It says 1:1.0.4-6ubuntu3.

So it's 1.0 ? It's fairly old, that would explain.

> > if you don't give an axis
> > parameter, you should get the median of the flattened array, therefore a
> > scalar, not an array.
>
> Not for my version.

Indeed. Looks like the default axis changed from 0 in 1.0 to None in the 
incoming 1.2. But that's a detail at this point.

> > Anyway: you should use ma.median for masked arrays. Else, you're just
> > keeping the NaNs where they were.
>
> That will be the problem. My version does not have median or mean methods
> for masked arrays, only the average() method.

The method mean has always been around for masked arrays, so has the 
corresponding function. But I'm surprised, median has been in numpy.ma.extras 
for a while. Maybe not 1.0...

> According to this page:
>
> http://www.scipy.org/Download
>
> 1.1.0 is the latest release. 

You need to update your internet ;) 1.1.1 was released 6 weeks ago.

> Do I need to use an SVN build to get the 
> ma.median functionality?

No, you can install 1.1.1, that should work. 
Note that I just fixed a bug in median in SVN (it would fail when trying to 
get the median of a 2D array with axis=1), so you may want to check this one 
instead if you feel like it. You can still use 1.1.1 : as a quick workaround 
the forementioned bug, use ma.median(a.T, axis=0) instead of 
ma.median(a,axis=1) when working w/ 2D arrays.



More information about the Numpy-discussion mailing list