Created
May 24, 2019 13:57
-
-
Save eLtronicsVilla/2c9b9c90e140e7e1d7c3f6d1092dfb89 to your computer and use it in GitHub Desktop.
This file contains 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
# Generalization of median is quantile. Which represent the value less than which a certain percentile of the data lies. | |
num = [100, 49, 41, 40, 25] | |
def quantile(x, p): | |
"""returns the pth-percentile value in x data list""" | |
p_index = int(p * len(x)) | |
return sorted(x)[p_index] | |
print("quantile",quantile(num, 0.10)) | |
def interquartile_range(data): | |
return quantile(data,0.75) - quantile(data,0.25) | |
print("interquartile_range:",interquartile_range(num)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment