summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorJaime <jaime.frio@gmail.com>2015-05-28 18:21:47 -0700
committerJaime <jaime.frio@gmail.com>2015-05-28 18:21:47 -0700
commita3ffea107820c06a62fd74c4dff1a51bd1ebb284 (patch)
treed1976adbaab15adb4e9d85c35aceead0dccbd788 /numpy/core/fromnumeric.py
parent467d4e16d77a2e7c131aac53c639e82b754578c7 (diff)
parent0c89ba8b7f0e7b83d9662d88b1913d92d58a2bdb (diff)
downloadnumpy-a3ffea107820c06a62fd74c4dff1a51bd1ebb284.tar.gz
Merge pull request #5925 from mortada/std_docs
DOC: np.std and np.var docstring examples are outdated
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 778cef204..e581f0d49 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -2939,16 +2939,16 @@ def std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
In single precision, std() can be inaccurate:
- >>> a = np.zeros((2,512*512), dtype=np.float32)
- >>> a[0,:] = 1.0
- >>> a[1,:] = 0.1
+ >>> a = np.zeros((2, 512*512), dtype=np.float32)
+ >>> a[0, :] = 1.0
+ >>> a[1, :] = 0.1
>>> np.std(a)
- 0.45172946707416706
+ 0.45000005
Computing the standard deviation in float64 is more accurate:
>>> np.std(a, dtype=np.float64)
- 0.44999999925552653
+ 0.44999999925494177
"""
if type(a) is not mu.ndarray:
@@ -3035,7 +3035,7 @@ def var(a, axis=None, dtype=None, out=None, ddof=0,
Examples
--------
- >>> a = np.array([[1,2],[3,4]])
+ >>> a = np.array([[1, 2], [3, 4]])
>>> np.var(a)
1.25
>>> np.var(a, axis=0)
@@ -3045,18 +3045,18 @@ def var(a, axis=None, dtype=None, out=None, ddof=0,
In single precision, var() can be inaccurate:
- >>> a = np.zeros((2,512*512), dtype=np.float32)
- >>> a[0,:] = 1.0
- >>> a[1,:] = 0.1
+ >>> a = np.zeros((2, 512*512), dtype=np.float32)
+ >>> a[0, :] = 1.0
+ >>> a[1, :] = 0.1
>>> np.var(a)
- 0.20405951142311096
+ 0.20250003
Computing the variance in float64 is more accurate:
>>> np.var(a, dtype=np.float64)
- 0.20249999932997387
+ 0.20249999932944759
>>> ((1-0.55)**2 + (0.1-0.55)**2)/2
- 0.20250000000000001
+ 0.2025
"""
if type(a) is not mu.ndarray: