Created
November 1, 2013 17:04
-
-
Save eriktaubeneck/7268489 to your computer and use it in GitHub Desktop.
Function for finding the percentile of a value `v` among a list of values `l`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def percentile_at(l,v): | |
n = len(l) | |
x = len({i for i in l if i <= v}) | |
return int(round(100*x/float(n))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment