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

Jonathan Helmus jjhelmus@gmail....
Wed Dec 5 11:33:20 CST 2012


On 12/04/2012 11:43 AM, Skipper Seabold wrote:
> On Tue, Dec 4, 2012 at 11:44 AM, Jonathan Helmus<jjhelmus@gmail.com>  wrote:
>> On 12/04/2012 11:26 AM, Pauli Virtanen wrote:
>>> 04.12.2012 18:20, Jonathan Helmus kirjoitti:
>>>> numpy.percentile can can accept a sequence of percentiles as the second
>>>> parameter:
>>>>
>>>> In [8]: probs = [10.0, 30.0, 50.0, 70.0, 90.0]
>>>>
>>>> In [9]: a = np.arange(100)
>>>>
>>>> In [10]: np.percentile(a, probs)
>>> [clip]
>>>> In [11]: [scipy.stats.scoreatpercentile(a, i) for i in probs]
>>>> Out[11]:
>>> [clip]
>>>
>>> It could be useful if someone would take a look if that the
>>> implementation in scipy can be easily adapted for that.
>>>
>> NumPy's implementation is pure python and quite straightforward, I'll
>> put together a pull request to include similar functionality in SciPy.
>> Adding the limit optional parameter shouldn't be too hard.
>>
> Great thanks for looking at this. Could you also look at adding an
> axis keyword to scoreatpercentile? Should be simple, but IIRC this was
> missing the last time I looked at this.
>
> Skipper
I made a pull request that adds sequences of percentiles and an axis 
keyword to the scoreatpercentile function. 
https://github.com/scipy/scipy/pull/374

We can move any further discussion to the PR comments.

     - Jonathan Helmus


More information about the SciPy-User mailing list