[SciPy-User] equivalent of R quantile() function in scipy

Skipper Seabold jsseabold@gmail....
Tue Dec 4 10:14:48 CST 2012


On Tue, Dec 4, 2012 at 10:55 AM, servant mathieu
<servant.mathieu@gmail.com> wrote:
> Dear list,
>
> From an array X of values, the quantile () function in R can return the
> score at any given specified quantile : e.g., quant_values = quantile (X,
> probs = c(.1, .3, .5, .7, .9)).
>
> The scoreatpercentile() function in scipy seems to to the same stuff.
> However, you can specify only one quantile per function call e.g.
> quant_value = scoreatpercentile (X, per = 10) etc..
>

Yes, this is pretty annoying.

> Is it possible to return more than one quantile per function call?

You can use percentile in numpy. Note that it expects the percentiles in 0-100.

quants = np.percentile(np.random.randn(25), [10, 30, 50, 70, 90])

Skipper


More information about the SciPy-User mailing list