[Numpy-discussion] Median / mean functionality confusing?

Sven Schreiber svetosch at gmx.net
Thu May 24 11:09:52 EDT 2007


Matthew Brett schrieb:
> Hi,
> 
> Does anyone else find this unexpected?
> 
> In [93]: import numpy as N
> In [94]: a = N.arange(10).reshape(5,2)
> In [95]: N.mean(a)
> Out[95]: 4.5
> In [96]: N.median(a)
> Out[96]: array([4, 5])
> 
> i.e. shouldn't median have the same axis, dtype, default axis=None
> behavior as mean?
> 

Well according to the docstring it doesn't even have an axis argument:

median(m)
    median(m) returns a median of m along the first dimension of m.

but I agree that it would be useful if it did!

Regarding dtype, I disagree. Why do you want to force the result to be a
float?

cheers,
sven



More information about the NumPy-Discussion mailing list