There are probably better words to describe this question, however what I am trying to do is the opposite of np.percentile(). I have a list of n numbers, and I want to see what percentile of them are smaller than a given value. Right now the way I get this value is by continuously trying different decimals. What I want Numpy to tell me is this:
Given threshold = 0.20 (input), about 99.847781% (output) of the items in list
dare below this percentile.
What I do right now to get this number is pretty sketchy:
>>> np.percentile(np.absolute(d), 99.847781) 0.19999962082827874 >>> np.percentile(np.absolute(d), 99.8477816) 0.19999989822334402 >>> np.percentile(np.absolute(d), 99.8477817) 0.19999994445584851 >>> np.percentile(np.absolute(d), 99.8477818) 0.19999999068835939 ...
sum(d < given_value) / len(d)? If you're usingpython2you'd have to cast one of the operands tofloat