Skip to content

Prevent floating-point error in decile calculation #235

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

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

anth-volk
Copy link
Collaborator

Fixes #234.

Unfortunately, the original intended implementation of just attempting to round erroneously high values in rank() was not sufficient, so this also adds the use of np.minimum() to each of the -ile functions to ensure no value exceeds their intended max.

I have not added tests, as I am unfamiliar with the testing protocol of this package. I am happy to do so, but am unsure how to simulate the floating point error necessary to reproduce this bug, other than adding a large dataset that actively triggers it, then testing against that. I am happy to do so, if desired.

@MaxGhenis
Copy link
Collaborator

Runner taking longer than usual so merging

@MaxGhenis MaxGhenis merged commit f26e19f into PolicyEngine:master Oct 23, 2024
4 of 5 checks passed
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

Successfully merging this pull request may close these issues.

decile_rank sometimes applies decile of 11 to the uppermost value in the dataset
2 participants