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

Rounding error fix on WeightedIndex::update_weights() #956

Merged
merged 1 commit into from
Mar 27, 2020

Conversation

facorread
Copy link
Contributor

WeightedIndex::update_weights() uses subtraction on old_w. Rounding errors, particularly on f32, may bring total_weight to below 0. This PR makes sure a negative total_weight results in an error.

This replaces PR #955 which was invalidated after a merge. Thanks for your consideration!

WeightedIndex::update_weights() uses subtraction on old_w. Rounding errors, particularly on f32, may bring total_weight to below 0. This PR makes sure a negative total_weight results in an error.

This replaces PR rust-random#955 which was invalidated after a merge. Thanks for your consideration!
Copy link
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the trouble. You should be able to force-push to your own fork, but never mind.

@dhardy dhardy merged commit 2962dea into rust-random:master Mar 27, 2020
@facorread facorread deleted the patch-1 branch March 27, 2020 16:02
@facorread
Copy link
Contributor Author

I wanted to leave this example for future reference, for anyone who needs to understand this rounding error. Thank you.

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.

None yet

2 participants