-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid GeometricMean overflow by using exp and log
This PR complicates a formula a bit to avoid overflows. Geometric mean of 100 numbers around 1 billion gets us overflow as multiplying them yields infinity. Numeric roots from that still return infinity. We can take logarithm of all numbers to avoid most prominent overflows that manifest themselves for just few numbers. Add tests: Test with 0 in input failed in previous implementation. Test with more larger values show the overflow issue.
- Loading branch information
Showing
2 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters