joelgrus / data-science-from-scratch

code for Data Science From Scratch book
MIT License
8.63k stars 4.5k forks source link

`def quantile (x, p)` correction in statistics.py #38

Open mdusan opened 7 years ago

mdusan commented 7 years ago

If the value p = 1 (100%) is chosen, sorted(x)[p_index] is out of bounds because p_index = p * len(x) = 1 * len(x) = len(x) and the list x is indexed from [0] to [len(x)-1].

Correction proposed (line 50 of statistics.py):