[Numpy-discussion] Re: Ways to achieve faster np.nanpercentile() calculation?

2022-09-19 Thread Abel AOUN
Hi Aron,

There is an implementation of nanpercentile for ndarray in xclim[0]. See 
`calc_perc`[1]
Bear in mind it's not exposed in the public API, so I would only use it as an 
example implementation.
You may also find a performance script and report (quite poorly written, sorry) 
on a gist[2]. I'm not sure how accurate it is against the latest numpy version.

Plus the interpolation configuration is limited to the 9 methods of R through 
alpha and beta parameter (similar to scipy `mquantiles`).
Thus, you can't use "nearest", "lower", "higher", "midpoint" methods but:
- "linear" (np default) would be alpha=1 and beta=1.
- "median_unbiased" (recommended default [3]) would be alpha=1/3 and beta=1/3.


Cheers,
Abel Aoun

[0] https://github.com/Ouranosinc/xclim
[1] https://github.com/Ouranosinc/xclim/blob/master/xclim/core/utils.py#L240
[2] https://gist.github.com/bzah/2a84d050b8a1aed1b40a2ed1526e1f12 
[3] 
https://www.researchgate.net/publication/222105754_Sample_Quantiles_in_Statistical_Packages

- Mail original -
De: "Aron Gergely" 
À: "Discussion of Numerical Python" 
Envoyé: Vendredi 16 Septembre 2022 10:56:28
Objet: [Numpy-discussion] Ways to achieve faster np.nanpercentile() calculation?

Hi all,

On my system, np.nanpercentile()  is orders of magnitude (>100x) slower 
than np.percentile().
I use numpy 1.23.1

Wondering if there is a way to speed it up.

I came across this workaround for 3D arrays:
https://krstn.eu/np.nanpercentile()-there-has-to-be-a-faster-way/

But I would need a generalized solution that works on N dimensions.
So I started adopting the above - but wondering if I am reinventing the 
wheel here?

Is there already a python package that implements a speedier 
nanpercentile for numpy? (similar idea as the 'Bottleneck' package?)
Or other known workarounds to achieve the same result?

Best regards,
Aron

___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: a...@cerfacs.fr
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] next NumPy Newcomers' Hour

2022-09-19 Thread Inessa Pawson
Our next NumPy Newcomers’ Hour will be held this Thursday, September 22nd
at 2 pm UTC. Join Mars Lee, a Quansight technical illustrator, for a Design
Jam to discuss what a NumPy contributor journey map should look like and
explore how it could look for you.

For more info about this event, visit:
https://hackmd.io/3f3otyyuTte3FU9y3QzsLg?both
Join us via Zoom:
https://us06web.zoom.us/j/82563808729?pwd=ZFU3Z2dMcXBGb05YemRsaGE1OW5nQT09

-- 
Cheers,
Inessa

Inessa Pawson
Contributor Experience Lead | NumPy
https://numpy.org/
GitHub: inessapawson
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com