diff options
author | Jaime <jaime.frio@gmail.com> | 2015-05-28 18:21:47 -0700 |
---|---|---|
committer | Jaime <jaime.frio@gmail.com> | 2015-05-28 18:21:47 -0700 |
commit | a3ffea107820c06a62fd74c4dff1a51bd1ebb284 (patch) | |
tree | d1976adbaab15adb4e9d85c35aceead0dccbd788 /numpy/core/fromnumeric.py | |
parent | 467d4e16d77a2e7c131aac53c639e82b754578c7 (diff) | |
parent | 0c89ba8b7f0e7b83d9662d88b1913d92d58a2bdb (diff) | |
download | numpy-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.py | 24 |
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: |