scipy.stats.scoreatpercentile(a, per, limit=(), interpolation_method='fraction')[source]

Calculate the score at the given per percentile of the sequence a.

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. Values of a outside this (closed) interval will be ignored.

The interpolation_method parameter supports three values, namely fraction (default), lower and higher. Interpolation is done only, if the desired quantile lies between two data points i and j. For fraction, the result is an interpolated value between i and j; for lower, the result is i, for higher the result is j.

Parameters :

a : ndarray

Values from which to extract score.

per : scalar

Percentile at which to extract score.

limit : tuple, optional

Tuple of two scalars, the lower and upper limits within which to compute the percentile.

interpolation : {‘fraction’, ‘lower’, ‘higher’}, optional

This optional parameter specifies the interpolation method to use, when the desired quantile lies between two data points i and j:

  • fraction: i + (j - i)*fraction, where fraction is the

    fractional part of the index surrounded by i and j.

-lower: i. - higher: j.

Returns :

score : float

Score at percentile.


>>> from scipy import stats
>>> a = np.arange(100)
>>> stats.scoreatpercentile(a, 50)

Previous topic


Next topic