When to use np.quantile and np.percentile?

I am trying to distinguish the scenario in which np.quantile() or np.percentile() should be used.

>>> import numpy as np >>> a = np.array([[10, 7, 4], [3, 2, 1]]) >>> np.quantile(a, 0.5) 3.5 >>> np.percentile(a, 50) 3.5 

Both of them give the same result and call _quantile_unchecked() in their implementation.

What are the best use cases?

1

1 Answer

They are equivalent. If you'd rather specify q from [0, 1], use np.quantile. For [0, 100], use np.percentile.

Docs:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like