diff options
| -rw-r--r-- | numpy/lib/function_base.py | 22 | ||||
| -rw-r--r-- | numpy/lib/histograms.py | 16 |
2 files changed, 28 insertions, 10 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index ff56196c3..f69604d6e 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -906,7 +906,7 @@ def copy(a, order='K', subok=False): >>> b[0] = 3 >>> b array([3, 2, 3]) - + Note that np.copy is a shallow copy and will not copy object elements within arrays. This is mainly important for arrays containing Python objects. The new array will contain the @@ -2696,7 +2696,7 @@ def corrcoef(x, y=None, rowvar=True, bias=np._NoValue, ddof=np._NoValue, *, relationship between the correlation coefficient matrix, `R`, and the covariance matrix, `C`, is - .. math:: R_{ij} = \\frac{ C_{ij} } { \\sqrt{ C_{ii} * C_{jj} } } + .. math:: R_{ij} = \\frac{ C_{ij} } { \\sqrt{ C_{ii} C_{jj} } } The values of `R` are between -1 and 1, inclusive. @@ -3984,18 +3984,21 @@ def percentile(a, inverted_cdf: method 1 of H&F [1]_. This method gives discontinuous results: + * if g > 0 ; then take j * if g = 0 ; then take i averaged_inverted_cdf: method 2 of H&F [1]_. This method give discontinuous results: + * if g > 0 ; then take j * if g = 0 ; then average between bounds closest_observation: method 3 of H&F [1]_. This method give discontinuous results: + * if g > 0 ; then take j * if g = 0 and index is odd ; then take j * if g = 0 and index is even ; then take i @@ -4003,24 +4006,28 @@ def percentile(a, interpolated_inverted_cdf: method 4 of H&F [1]_. This method give continuous results using: + * alpha = 0 * beta = 1 hazen: method 5 of H&F [1]_. This method give continuous results using: + * alpha = 1/2 * beta = 1/2 weibull: method 6 of H&F [1]_. This method give continuous results using: + * alpha = 0 * beta = 0 linear: method 7 of H&F [1]_. This method give continuous results using: + * alpha = 1 * beta = 1 @@ -4029,6 +4036,7 @@ def percentile(a, This method is probably the best method if the sample distribution function is unknown (see reference). This method give continuous results using: + * alpha = 1/3 * beta = 1/3 @@ -4037,6 +4045,7 @@ def percentile(a, This method is probably the best method if the sample distribution function is known to be normal. This method give continuous results using: + * alpha = 3/8 * beta = 3/8 @@ -4254,18 +4263,21 @@ def quantile(a, inverted_cdf: method 1 of H&F [1]_. This method gives discontinuous results: + * if g > 0 ; then take j * if g = 0 ; then take i averaged_inverted_cdf: method 2 of H&F [1]_. This method gives discontinuous results: + * if g > 0 ; then take j * if g = 0 ; then average between bounds closest_observation: method 3 of H&F [1]_. This method gives discontinuous results: + * if g > 0 ; then take j * if g = 0 and index is odd ; then take j * if g = 0 and index is even ; then take i @@ -4273,24 +4285,28 @@ def quantile(a, interpolated_inverted_cdf: method 4 of H&F [1]_. This method gives continuous results using: + * alpha = 0 * beta = 1 hazen: method 5 of H&F [1]_. This method gives continuous results using: + * alpha = 1/2 * beta = 1/2 weibull: method 6 of H&F [1]_. This method gives continuous results using: + * alpha = 0 * beta = 0 linear: method 7 of H&F [1]_. This method gives continuous results using: + * alpha = 1 * beta = 1 @@ -4299,6 +4315,7 @@ def quantile(a, This method is probably the best method if the sample distribution function is unknown (see reference). This method gives continuous results using: + * alpha = 1/3 * beta = 1/3 @@ -4307,6 +4324,7 @@ def quantile(a, This method is probably the best method if the sample distribution function is known to be normal. This method gives continuous results using: + * alpha = 3/8 * beta = 3/8 diff --git a/numpy/lib/histograms.py b/numpy/lib/histograms.py index 44e4b51c4..98182f1c4 100644 --- a/numpy/lib/histograms.py +++ b/numpy/lib/histograms.py @@ -562,7 +562,7 @@ def histogram_bin_edges(a, bins=10, range=None, weights=None): below, :math:`h` is the binwidth and :math:`n_h` is the number of bins. All estimators that compute bin counts are recast to bin width using the `ptp` of the data. The final bin count is obtained from - ``np.round(np.ceil(range / h))``. The final bin width is often less + ``np.round(np.ceil(range / h))``. The final bin width is often less than what is returned by the estimators below. 'auto' (maximum of the 'sturges' and 'fd' estimators) @@ -581,7 +581,7 @@ def histogram_bin_edges(a, bins=10, range=None, weights=None): datasets. The IQR is very robust to outliers. 'scott' - .. math:: h = \sigma \sqrt[3]{\frac{24 * \sqrt{\pi}}{n}} + .. math:: h = \sigma \sqrt[3]{\frac{24 \sqrt{\pi}}{n}} The binwidth is proportional to the standard deviation of the data and inversely proportional to cube root of ``x.size``. Can @@ -598,7 +598,7 @@ def histogram_bin_edges(a, bins=10, range=None, weights=None): does not take into account data variability. 'sturges' - .. math:: n_h = \log _{2}n+1 + .. math:: n_h = \log _{2}(n) + 1 The number of bins is the base 2 log of ``a.size``. This estimator assumes normality of data and is too conservative for @@ -607,9 +607,9 @@ def histogram_bin_edges(a, bins=10, range=None, weights=None): 'doane' .. math:: n_h = 1 + \log_{2}(n) + - \log_{2}(1 + \frac{|g_1|}{\sigma_{g_1}}) + \log_{2}\left(1 + \frac{|g_1|}{\sigma_{g_1}}\right) - g_1 = mean[(\frac{x - \mu}{\sigma})^3] + g_1 = mean\left[\left(\frac{x - \mu}{\sigma}\right)^3\right] \sigma_{g_1} = \sqrt{\frac{6(n - 2)}{(n + 1)(n + 3)}} @@ -1050,13 +1050,13 @@ def histogramdd(sample, bins=10, range=None, normed=None, weights=None, smin, smax = _get_outer_edges(sample[:,i], range[i]) try: n = operator.index(bins[i]) - + except TypeError as e: raise TypeError( "`bins[{}]` must be an integer, when a scalar".format(i) ) from e - - edges[i] = np.linspace(smin, smax, n + 1) + + edges[i] = np.linspace(smin, smax, n + 1) elif np.ndim(bins[i]) == 1: edges[i] = np.asarray(bins[i]) if np.any(edges[i][:-1] > edges[i][1:]): |
