[Numpy-svn] r3751 - in trunk/numpy: . core

numpy-svn at scipy.org numpy-svn at scipy.org
Sat May 12 15:58:50 EDT 2007


Author: charris
Date: 2007-05-12 14:58:43 -0500 (Sat, 12 May 2007)
New Revision: 3751

Modified:
   trunk/numpy/add_newdocs.py
   trunk/numpy/core/defmatrix.py
   trunk/numpy/core/fromnumeric.py
Log:
Add/edit documentation for mean, std, var.


Modified: trunk/numpy/add_newdocs.py
===================================================================
--- trunk/numpy/add_newdocs.py	2007-05-11 23:13:27 UTC (rev 3750)
+++ trunk/numpy/add_newdocs.py	2007-05-12 19:58:43 UTC (rev 3751)
@@ -332,7 +332,7 @@
 add_newdoc('numpy.core.multiarray','set_numeric_ops',
     """set_numeric_ops(op=func, ...)
 
-    Set some or all of the number methods for all array objects.  Don't
+    Set some or all of the number methods for all array objects.  Do not
     forget **dict can be used as the argument list.  Return the functions
     that were replaced, which can be stored and set later.
 
@@ -810,7 +810,7 @@
     """a.getfield(dtype, offset) -> field of array as given type.
 
     Returns a field of the given array as a certain type. A field is a view of
-    the array's data with each itemsize determined by the given type and the
+    the array data with each itemsize determined by the given type and the
     offset into the current array.
 
     """))
@@ -832,16 +832,38 @@
 
 
 add_newdoc('numpy.core.multiarray', 'ndarray', ('mean',
-    """a.mean(axis=None, dtype=None)
+    """a.mean(axis=None, dtype=None, out=None) -> mean
 
-      Average the array over the given axis.  If the axis is None,
-      average over all dimensions of the array.  Equivalent to
+    Returns the average of the array elements.  The average is taken over the
+    flattened array by default, otherwise over the specified axis.
+    
+    :Parameters:
+        axis : integer
+            Axis along which the means are computed. The default is
+            to compute the standard deviation of the flattened array.
+        dtype : type
+            Type to use in computing the means. For arrays of
+            integer type the default is float32, for arrays of float types it
+            is the same as the array type.
+        out : ndarray
+            Alternative output array in which to place the result. It must have
+            the same shape as the expected output but the type will be cast if
+            necessary.
 
-        a.sum(axis, dtype) / size(a, axis).
+    :Returns:
+        mean : The return type varies, see above.
+            A new array holding the result is returned unless out is specified,
+            in which case a reference to out is returned.
 
-      The optional dtype argument is the data type for intermediate
-      calculations in the sum.
+    :SeeAlso:
+        - var : variance
+        - std : standard deviation
 
+    Notes
+    -----
+        The mean is the sum of the elements along the axis divided by the
+        number of elements.
+
     """))
 
 
@@ -1072,16 +1094,40 @@
 add_newdoc('numpy.core.multiarray', 'ndarray', ('std',
     """a.std(axis=None, dtype=None, out=None) -> standard deviation.
 
-    The standard deviation isa measure of the spread of a
-    distribution.
+    Returns the standard deviation of the array elements, a measure of the
+    spread of a distribution. The standard deviation is computed for the
+    flattened array by default, otherwise over the specified axis.
 
-    The standard deviation is the square root of the average of the
-    squared deviations from the mean, i.e.
-        std = sqrt(mean((x - x.mean())**2,axis=0)).
+    :Parameters:
+        axis : integer
+            Axis along which the standard deviation is computed. The default is
+            to compute the standard deviation of the flattened array.
+        dtype : type
+            Type to use in computing the standard deviation. For arrays of
+            integer type the default is float32, for arrays of float types it
+            is the same as the array type.
+        out : ndarray
+            Alternative output array in which to place the result. It must have
+            the same shape as the expected output but the type will be cast if
+            necessary.
 
-    For multidimensional arrays, std is computed by default along the
-    first axis.
+    :Returns:
+        standard deviation : The return type varies, see above.
+            A new array holding the result is returned unless out is specified,
+            in which case a reference to out is returned.
 
+    :SeeAlso:
+        - var : variance
+        - mean : average
+
+    Notes
+    -----
+
+      The standard deviation is the square root of the average of the squared
+      deviations from the mean, i.e. var = sqrt(mean((x - x.mean())**2)).  The
+      computed standard deviation is biased, i.e., the mean is computed by
+      dividing by the number of elements, N, rather than by N-1.
+
     """))
 
 
@@ -1224,8 +1270,42 @@
 
 
 add_newdoc('numpy.core.multiarray', 'ndarray', ('var',
-    """a.var(axis=None, dtype=None)
+    """a.var(axis=None, dtype=None, out=None) -> variance
 
+    Returns the variance of the array elements, a measure of the spread of a
+    distribution.  The variance is computed for the flattened array by default,
+    otherwise over the specified axis.
+
+    :Parameters:
+        axis : integer
+            Axis along which the variance is computed. The default is to
+            compute the variance of the flattened array.
+        dtype : type
+            Type to use in computing the variance. For arrays of integer type
+            the default is float32, for arrays of float types it is the same as
+            the array type.
+        out : ndarray
+            Alternative output array in which to place the result. It must have
+            the same shape as the expected output but the type will be cast if
+            necessary.
+
+    :Returns:
+        variance : The return type varies, see above.
+            A new array holding the result is returned unless out is specified,
+            in which case a reference to out is returned.
+
+    :SeeAlso:
+        - std : standard deviation
+        - mean: average
+
+    Notes
+    -----
+
+      The variance is the average of the squared deviations from the mean, i.e.
+      var = mean((x - x.mean())**2).  The computed variance is biased, i.e.,
+      the mean is computed by dividing by the number of elements, N, rather
+      than by N-1.
+
     """))
 
 

Modified: trunk/numpy/core/defmatrix.py
===================================================================
--- trunk/numpy/core/defmatrix.py	2007-05-11 23:13:27 UTC (rev 3750)
+++ trunk/numpy/core/defmatrix.py	2007-05-12 19:58:43 UTC (rev 3751)
@@ -241,12 +241,121 @@
         return N.ndarray.sum(self, axis, dtype, out)._align(axis)
 
     def mean(self, axis=None, out=None):
+        """Compute the mean along the specified axis.
+
+        Returns the average of the array elements.  The average is taken over
+        the flattened array by default, otherwise over the specified axis.
+
+        :Parameters:
+            axis : integer
+                Axis along which the means are computed. The default is
+                to compute the standard deviation of the flattened array.
+            dtype : type
+                Type to use in computing the means. For arrays of integer type
+                the default is float32, for arrays of float types it is the
+                same as the array type.
+            out : ndarray
+                Alternative output array in which to place the result. It must
+                have the same shape as the expected output but the type will be
+                cast if necessary.
+
+        :Returns:
+            mean : The return type varies, see above.
+                A new array holding the result is returned unless out is
+                specified, in which case a reference to out is returned.
+
+        :SeeAlso:
+            - var : variance
+            - std : standard deviation
+
+        Notes
+        -----
+            The mean is the sum of the elements along the axis divided by the
+            number of elements.
+
+        """
         return N.ndarray.mean(self, axis, out)._align(axis)
 
     def std(self, axis=None, dtype=None, out=None):
+        """Compute the standard deviation along the specified axis.
+
+        Returns the standard deviation of the array elements, a measure of the
+        spread of a distribution. The standard deviation is computed for the
+        flattened array by default, otherwise over the specified axis.
+
+        :Parameters:
+            axis : integer
+                Axis along which the standard deviation is computed. The
+                default is to compute the standard deviation of the flattened
+                array.
+            dtype : type
+                Type to use in computing the standard deviation. For arrays of
+                integer type the default is float32, for arrays of float types
+                it is the same as the array type.
+            out : ndarray
+                Alternative output array in which to place the result. It must
+                have the same shape as the expected output but the type will be
+                cast if necessary.
+
+        :Returns:
+            standard deviation : The return type varies, see above.
+                A new array holding the result is returned unless out is
+                specified, in which case a reference to out is returned.
+
+        :SeeAlso:
+            - var : variance
+            - mean : average
+
+        Notes
+        -----
+
+          The standard deviation is the square root of the average of the
+          squared deviations from the mean, i.e. var = sqrt(mean((x -
+          x.mean())**2)).  The computed standard deviation is biased, i.e., the
+          mean is computed by dividing by the number of elements, N, rather
+          than by N-1.
+
+        """
         return N.ndarray.std(self, axis, dtype, out)._align(axis)
 
     def var(self, axis=None, dtype=None, out=None):
+        """Compute the variance along the specified axis.
+
+        Returns the variance of the array elements, a measure of the spread of
+        a distribution.  The variance is computed for the flattened array by
+        default, otherwise over the specified axis.
+
+        :Parameters:
+            axis : integer
+                Axis along which the variance is computed. The default is to
+                compute the variance of the flattened array.
+            dtype : type
+                Type to use in computing the variance. For arrays of integer
+                type the default is float32, for arrays of float types it is
+                the same as the array type.
+            out : ndarray
+                Alternative output array in which to place the result. It must
+                have the same shape as the expected output but the type will be
+                cast if necessary.
+
+        :Returns:
+            variance : depends, see above
+                A new array holding the result is returned unless out is
+                specified, in which case a reference to out is returned.
+
+        :SeeAlso:
+            - std : standard deviation
+            - mean : average
+
+        Notes
+        -----
+
+          The variance is the average of the squared deviations from the mean,
+          i.e.  var = mean((x - x.mean())**2).  The computed variance is
+          biased, i.e., the mean is computed by dividing by the number of
+          elements, N, rather than by N-1.
+
+        """
         return N.ndarray.var(self, axis, dtype, out)._align(axis)
 
     def prod(self, axis=None, dtype=None, out=None):

Modified: trunk/numpy/core/fromnumeric.py
===================================================================
--- trunk/numpy/core/fromnumeric.py	2007-05-11 23:13:27 UTC (rev 3750)
+++ trunk/numpy/core/fromnumeric.py	2007-05-12 19:58:43 UTC (rev 3751)
@@ -691,12 +691,38 @@
 around = round_
 
 def mean(a, axis=None, dtype=None, out=None):
-    """mean(a, axis=None, dtype=None)
-    Return the arithmetic mean.
+    """Compute the mean along the specified axis.
 
-    The mean is the sum of the elements divided by the number of elements.
+    Returns the average of the array elements.  The average is taken over the
+    flattened array by default, otherwise over the specified axis.
 
-    See also: average
+    :Parameters:
+        axis : integer
+            Axis along which the means are computed. The default is
+            to compute the standard deviation of the flattened array.
+        dtype : type
+            Type to use in computing the means. For arrays of
+            integer type the default is float32, for arrays of float types it
+            is the same as the array type.
+        out : ndarray
+            Alternative output array in which to place the result. It must have
+            the same shape as the expected output but the type will be cast if
+            necessary.
+
+    :Returns:
+        mean : The return type varies, see above.
+            A new array holding the result is returned unless out is specified,
+            in which case a reference to out is returned.
+
+    :SeeAlso:
+        - var : variance
+        - std : standard deviation
+
+    Notes
+    -----
+        The mean is the sum of the elements along the axis divided by the
+        number of elements.
+
     """
     try:
         mean = a.mean
@@ -704,14 +730,44 @@
         return _wrapit(a, 'mean', axis, dtype, out)
     return mean(axis, dtype, out)
 
+
 def std(a, axis=None, dtype=None, out=None):
-    """std(sample, axis=None, dtype=None)
-    Return the standard deviation, a measure of the spread of a distribution.
+    """Compute the standard deviation along the specified axis.
 
-    The standard deviation is the square root of the average of the squared
-    deviations from the mean, i.e. std = sqrt(mean((x - x.mean())**2)).
+    Returns the standard deviation of the array elements, a measure of the
+    spread of a distribution. The standard deviation is computed for the
+    flattened array by default, otherwise over the specified axis.
 
-    See also: var
+    :Parameters:
+        axis : integer
+            Axis along which the standard deviation is computed. The default is
+            to compute the standard deviation of the flattened array.
+        dtype : type
+            Type to use in computing the standard deviation. For arrays of
+            integer type the default is float32, for arrays of float types it
+            is the same as the array type.
+        out : ndarray
+            Alternative output array in which to place the result. It must have
+            the same shape as the expected output but the type will be cast if
+            necessary.
+
+    :Returns:
+        standard deviation : The return type varies, see above.
+            A new array holding the result is returned unless out is specified,
+            in which case a reference to out is returned.
+
+    :SeeAlso:
+        - var : variance
+        - mean : average
+
+    Notes
+    -----
+
+      The standard deviation is the square root of the average of the squared
+      deviations from the mean, i.e. var = sqrt(mean((x - x.mean())**2)).  The
+      computed standard deviation is biased, i.e., the mean is computed by
+      dividing by the number of elements, N, rather than by N-1.
+
     """
     try:
         std = a.std
@@ -719,14 +775,44 @@
         return _wrapit(a, 'std', axis, dtype, out)
     return std(axis, dtype, out)
 
+
 def var(a, axis=None, dtype=None, out=None):
-    """var(sample, axis=None, dtype=None)
-    Return the variance, a measure of the spread of a distribution.
+    """Compute the variance along the specified axis.
 
-    The variance is the average of the squared deviations from the mean,
-    i.e. var = mean((x - x.mean())**2).
+    Returns the variance of the array elements, a measure of the spread of a
+    distribution.  The variance is computed for the flattened array by default,
+    otherwise over the specified axis.
 
-    See also: std
+    :Parameters:
+        axis : integer
+            Axis along which the variance is computed. The default is to
+            compute the variance of the flattened array.
+        dtype : type
+            Type to use in computing the variance. For arrays of integer type
+            the default is float32, for arrays of float types it is the same as
+            the array type.
+        out : ndarray
+            Alternative output array in which to place the result. It must have
+            the same shape as the expected output but the type will be cast if
+            necessary.
+
+    :Returns:
+        variance : depends, see above
+            A new array holding the result is returned unless out is specified,
+            in which case a reference to out is returned.
+
+    :SeeAlso:
+        - std : standard deviation
+        - mean : average
+
+    Notes
+    -----
+
+      The variance is the average of the squared deviations from the mean, i.e.
+      var = mean((x - x.mean())**2).  The computed variance is biased, i.e.,
+      the mean is computed by dividing by the number of elements, N, rather
+      than by N-1.
+
     """
     try:
         var = a.var




More information about the Numpy-svn mailing list