summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorrgommers <ralf.gommers@googlemail.com>2011-03-03 14:13:28 +0800
committerrgommers <ralf.gommers@googlemail.com>2011-03-03 14:13:28 +0800
commit821afc8f1376a634612e182903c06a0c9c556d94 (patch)
tree909d7f649c4db817a1c0f1e8fc9f1934584242b9 /numpy/lib/function_base.py
parent85813a9a2eb163582cb518f0fe5d632b662ad0c7 (diff)
downloadnumpy-821afc8f1376a634612e182903c06a0c9c556d94.tar.gz
DOC: commit some more fixes from the doc wiki.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 033e18f8e..b2d2856d6 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -2921,22 +2921,22 @@ def percentile(a, q, axis=None, out=None, overwrite_input=False):
a : array_like
Input array or object that can be converted to an array.
q : float in range of [0,100] (or sequence of floats)
- percentile to compute which must be between 0 and 100 inclusive
- axis : {None, int}, optional
- Axis along which the percentiles are computed. The default (axis=None)
+ Percentile to compute which must be between 0 and 100 inclusive.
+ axis : int, optional
+ Axis along which the percentiles are computed. The default (None)
is to compute the median along a flattened version of the array.
out : ndarray, optional
Alternative output array in which to place the result. It must
have the same shape and buffer length as the expected output,
but the type (of the output) will be cast if necessary.
- overwrite_input : {False, True}, optional
- If True, then allow use of memory of input array (a) for
+ overwrite_input : bool, optional
+ If True, then allow use of memory of input array `a` for
calculations. The input array will be modified by the call to
median. This will save memory when you do not need to preserve
the contents of the input array. Treat the input as undefined,
- but it will probably be fully or partially sorted. Default is
- False. Note that, if `overwrite_input` is True and the input
- is not already an ndarray, an error will be raised.
+ but it will probably be fully or partially sorted.
+ Default is False. Note that, if `overwrite_input` is True and the
+ input is not already an array, an error will be raised.
Returns
-------
@@ -2954,10 +2954,10 @@ def percentile(a, q, axis=None, out=None, overwrite_input=False):
Notes
-----
Given a vector V of length N, the qth percentile of V is the qth ranked
- value in a sorted copy of V. A weighted average of the two nearest neighbors
- is used if the normalized ranking does not match q exactly.
- The same as the median if q is 0.5; the same as the min if q is 0;
- and the same as the max if q is 1
+ value in a sorted copy of V. A weighted average of the two nearest
+ neighbors is used if the normalized ranking does not match q exactly.
+ The same as the median if ``q=0.5``, the same as the minimum if ``q=0``
+ and the same as the maximum if ``q=1``.
Examples
--------
@@ -2971,12 +2971,14 @@ def percentile(a, q, axis=None, out=None, overwrite_input=False):
array([ 6.5, 4.5, 2.5])
>>> np.percentile(a, 0.5, axis=1)
array([ 7., 2.])
+
>>> m = np.percentile(a, 0.5, axis=0)
>>> out = np.zeros_like(m)
>>> np.percentile(a, 0.5, axis=0, out=m)
array([ 6.5, 4.5, 2.5])
>>> m
array([ 6.5, 4.5, 2.5])
+
>>> b = a.copy()
>>> np.percentile(b, 0.5, axis=1, overwrite_input=True)
array([ 7., 2.])