I want to bin my data into 10 bins (histograms) using percentile ranges:
bins = [0, 10th-percentile(myData), 20th-percentile(myData), 30th..., 90th-percentile(myData), +inf]
So in order make a histogram out of my data, I just do:
import numpy as np
myBinnedData = np.histogram(myData, bins=bins)[0]
My problem is that I have several ties in myData
and whenever a tie spans two bins or more, np.histogram
will just put all the values in the first bin and leave the second one empty.
This is because the bin ranges will have two consecutive equal values (X-percentile(myData) == Y-percentile(myData)
How can I account for this?