bundles / scipy 1.17.1 / scipy / stats / _stats_py / scoreatpercentile
function
scipy.stats._stats_py:scoreatpercentile
source: /scipy/stats/_stats_py.py :1973
Signature
def scoreatpercentile ( a , per , limit = () , interpolation_method = fraction , axis = None ) Summary
Calculate the score at a given percentile of the input sequence.
Extended Summary
For example, the score at per=50 is the median. If the desired quantile lies between two data points, we interpolate between them, according to the value of interpolation. If the parameter limit is provided, it should be a tuple (lower, upper) of two values.
Parameters
a: array_likeA 1-D array of values from which to extract score.
per: array_likePercentile(s) at which to extract score. Values should be in range [0,100].
limit: tuple, optionalTuple of two scalars, the lower and upper limits within which to compute the percentile. Values of
aoutside this (closed) interval will be ignored.interpolation_method: {'fraction', 'lower', 'higher'}, optionalSpecifies the interpolation method to use, when the desired quantile lies between two data points
iandjThe following options are available (default is 'fraction'):'fraction':
i + (j - i) * fractionwherefractionis the fractional part of the index surrounded byiandj'lower':
i'higher':
j
axis: int, optionalAxis along which the percentiles are computed. Default is None. If None, compute over the whole array
a.
Returns
score: float or ndarrayScore at percentile(s).
Notes
This function will become obsolete in the future. For NumPy 1.9 and higher, numpy.percentile provides all the functionality that scoreatpercentile provides. And it's significantly faster. Therefore it's recommended to use numpy.percentile for users that have numpy >= 1.9.
Array API Standard Support
scoreatpercentile has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ⛔ PyTorch ⛔ ⛔ JAX ⛔ ⛔ Dask ⛔ n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
import numpy as np from scipy import stats a = np.arange(100)✓
stats.scoreatpercentile(a, 50)
✗See also
- numpy.percentile
- percentileofscore
Aliases
-
scipy.stats.scoreatpercentile