obspy.core.util.misc.scoreatpercentile

scoreatpercentile(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]
>>> scoreatpercentile(a, 25)
1.75
>>> scoreatpercentile(a, 50)
2.5
>>> scoreatpercentile(a, 75)
3.25
>>> a = [6, 47, 49, 15, 42, 41, 7, 255, 39, 43, 40, 36, 500]
>>> scoreatpercentile(a, 25, limit=(0, 100))
25.5
>>> scoreatpercentile(a, 50, limit=(0, 100))
40
>>> scoreatpercentile(a, 75, limit=(0, 100))
42.5

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

Copyright (c) Gary Strangman