[Numpy-svn] r5607 - trunk/numpy/ma

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Aug 4 16:16:56 EDT 2008


Author: pierregm
Date: 2008-08-04 15:16:48 -0500 (Mon, 04 Aug 2008)
New Revision: 5607

Modified:
   trunk/numpy/ma/extras.py
Log:
* extras: fixed the definition of median

Modified: trunk/numpy/ma/extras.py
===================================================================
--- trunk/numpy/ma/extras.py	2008-08-04 18:06:12 UTC (rev 5606)
+++ trunk/numpy/ma/extras.py	2008-08-04 20:16:48 UTC (rev 5607)
@@ -360,21 +360,18 @@
 
 
 
-def median(a, axis=0, out=None, overwrite_input=False):
+def median(a, axis=None, out=None, overwrite_input=False):
     """Compute the median along the specified axis.
 
-    Returns the median of the array elements.  The median is taken
-    over the first axis of the array by default, otherwise over
-    the specified axis.
+    Returns the median of the array elements.
 
     Parameters
     ----------
     a : array-like
         Input array or object that can be converted to an array
-    axis : {int, None}, optional
-        Axis along which the medians are computed. The default is to
-        compute the median along the first dimension.  axis=None
-        returns the median of the flattened array
+    axis : {None, int}, optional
+        Axis along which the medians are computed. The default (axis=None) is to
+        compute the median along a flattened version of the array.
     out : {None, ndarray}, optional
         Alternative output array in which to place the result. It must
         have the same shape and buffer length as the expected output
@@ -402,9 +399,9 @@
 
     Notes
     -----
-    Given a vector V length N, the median of V is the middle value of
-    a sorted copy of V (Vs) - i.e. Vs[(N-1)/2], when N is odd. It is
-    the mean of the two middle values of Vs, when N is even.
+    Given a vector V with N non masked values, the median of V is the middle 
+    value of a sorted copy of V (Vs) - i.e. Vs[(N-1)/2], when N is odd, or
+    {Vs[N/2 - 1] + Vs[N/2]}/2. when N is even.
 
     """
     def _median1D(data):




More information about the Numpy-svn mailing list