[Numpy-discussion] Medians that ignore values

Peter Saffrey pzs@dcs.gla.ac...
Thu Sep 18 12:31:18 CDT 2008


Pierre GM <pgmdevlist <at> gmail.com> writes:

> Mmh, typo?
>

Yes, apologies. I was aiming for thorough, but ended up just careless. It's been
a long day.
 
> Ohoh. What version of numpy are you using ? 

The version in the Ubuntu package repository. It says 1:1.0.4-6ubuntu3.

> 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.

>>> a = rand(10,3)
>>> a
array([[ 0.1269796 ,  0.43003978,  0.4700416 ],
       [ 0.28867077,  0.85265318,  0.35908364],
       [ 0.72967127,  0.41856028,  0.54724918],
       [ 0.28821876,  0.69684144,  0.54647616],
       [ 0.09592476,  0.83704808,  0.52425368],
       [ 0.743552  ,  0.44433314,  0.7362179 ],
       [ 0.4283931 ,  0.13305385,  0.68422292],
       [ 0.68860674,  0.15057373,  0.99206493],
       [ 0.31846329,  0.77237046,  0.986883  ],
       [ 0.4578616 ,  0.4580833 ,  0.97754176]])
>>> median(a.T)
array([ 0.43003978,  0.35908364,  0.54724918,  0.54647616,  0.52425368,
        0.7362179 ,  0.4283931 ,  0.68860674,  0.77237046,  0.4580833 ])

> 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.

According to this page:

http://www.scipy.org/Download

1.1.0 is the latest release. Do I need to use an SVN build to get the ma.median
functionality?

Peter





More information about the Numpy-discussion mailing list