I have an array that I want to convert to percentiles. For example, let's say I have a normally distributed array:
import numpy as np
import matplotlib.pyplot as plt
arr = np.random.normal(0, 1, 1000)
plt.hist(arr)

For each value in this array, I want to calculate the percentile of this value (for example, 0 is the 50th percentile of the above distribution, so 0 → 0.5). The result should be evenly distributed, since each percentile should have equal weight.

I found np.percentile, but this function returns the value given for the array and quantile , and I need to return the quantile, the given array and value .
Is there a relatively effective way to do this?
Chris source
share