Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percentile Calculation #4

Open
vlad-bezden opened this issue May 2, 2017 · 3 comments
Open

Percentile Calculation #4

vlad-bezden opened this issue May 2, 2017 · 3 comments

Comments

@vlad-bezden
Copy link

Hi,
In your example code/chapter3/solutions/percentile_score.py you have following code:

    if percentile == 0:
        return data[0]
    elif percentile == 100:
        return data[-1]

so for percentile == 0 it will return 1 and for percentile == 100 it returns 14
However based on the link that you provided Calculating Percentiles
percentile for 1 should be 7.1 and for 14 it should be 92.9
I checked other web sites and they all have different logic but most of them accept percentile from 1-99. 0 and 100 are invalid numbers.
So is there an error in your code?

@vlad-bezden
Copy link
Author

I also tried code to run for percentile below 7.1 and above 92.9 and code failed, because indexes out of range.

@amitsaha
Copy link
Contributor

Thanks for the report @vlad-bezden . I think you have hit a bug in the code (or the method itself). I will double check. In the meantime, can you please try the "Microsoft Excel" version of percentile calculation that i have at https://github.com/doingmathwithpython/code/blob/master/chapter3/solutions/percentile_score_microsoft_excel.py and see how that works for you?

@olegxrom
Copy link

Fixed the issue, please, review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants