obspy.core.util.misc.score_at_percentile

score_at_percentile(values, per, limit=(), issorted=True)[source]

Calculates 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.

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.

Examples

>>> a = [1, 2, 3, 4]
>>> score_at_percentile(a, 25)
1.75
>>> score_at_percentile(a, 50)
2.5
>>> score_at_percentile(a, 75)
3.25
>>> a = [6, 47, 49, 15, 42, 41, 7, 255, 39, 43, 40, 36, 500]
>>> score_at_percentile(a, 25, limit=(0, 100))
25.5
>>> score_at_percentile(a, 50, limit=(0, 100))
40
>>> score_at_percentile(a, 75, limit=(0, 100))
42.5

This function is taken from scipy.stats.score_at_percentile().

Copyright (c) Gary Strangman