Closed zakir8251 closed 2 years ago
https://github.com/AllenDowney/ThinkStats2/blob/e43e7c10e9389cab35173eba753f53facea4b130/book/book.tex#L2907
def Percentile2(scores, percentile_rank): scores.sort() index = percentile_rank * (len(scores)-1) // 100 return scores[index]
Instead of index = percentile_rank (len(scores)-1) // 100 A more intuitive formula is:- index = (percentile_rank (len(scores)) // 100) -1 or even better:- index = percentile_rank * (len(scores)) // 100 return[index-1] #since indexes start with 0
https://github.com/AllenDowney/ThinkStats2/blob/e43e7c10e9389cab35173eba753f53facea4b130/book/book.tex#L2907
def Percentile2(scores, percentile_rank): scores.sort() index = percentile_rank * (len(scores)-1) // 100 return scores[index]
Instead of index = percentile_rank (len(scores)-1) // 100 A more intuitive formula is:- index = (percentile_rank (len(scores)) // 100) -1 or even better:- index = percentile_rank * (len(scores)) // 100 return[index-1] #since indexes start with 0