Skip to content

Fix potential overflow in empirical accuracy calculation - #108

Closed
fc-jian wants to merge 1 commit into
jbloomlab:masterfrom
fc-jian:master
Closed

Fix potential overflow in empirical accuracy calculation#108
fc-jian wants to merge 1 commit into
jbloomlab:masterfrom
fc-jian:master

Conversation

@fc-jian

@fc-jian fc-jian commented Oct 24, 2025

Copy link
Copy Markdown

From issue #106 and fixed a problem in the previous PR #107

jbloom added a commit that referenced this pull request Oct 24, 2025
This pull request addresses [this issue](#106),
which was originally pointed out by @fc-jian.

The key point is that the computational of the empirical accuracy
(`consensus.empirical_accuracy`) ran into numerical issues if the
numbers were large as it involved computing very large numbers and
then taking their logs. In #106, @fc-jian originally proposed using
Stirling's approximation, and made a draft pull request #108 to fix that.

However, in looking more I discovered that the built-in python `gammaln`
function is even a better way to do this. I also updated the docs
to describe the new math being done.

This pull request therefore solves #106 and is in lieu of #108, as I
think it is a better solution.

@fc-jian, thanks so much for noting and flagging all of this!
@jbloom

jbloom commented Oct 24, 2025

Copy link
Copy Markdown
Member

@fc-jian, thanks so much for noticing this and proposing most of the solution. I am closing this pull request in lieu of #109, which is a slightly better implementation of a similar solution as explained in that pull request and in #106

@jbloom jbloom closed this Oct 24, 2025
jbloom added a commit that referenced this pull request Oct 24, 2025
This pull request addresses [this issue](#106),
which was originally pointed out by @fc-jian.

The key point is that the computational of the empirical accuracy
(`consensus.empirical_accuracy`) ran into numerical issues if the
numbers were large as it involved computing very large numbers and
then taking their logs. In #106, @fc-jian originally proposed using
Stirling's approximation, and made a draft pull request #108 to fix that.

However, in looking more I discovered that the built-in python `gammaln`
function is even a better way to do this. I also updated the docs
to describe the new math being done.

This pull request therefore solves #106 and is in lieu of #108, as I
think it is a better solution.

@fc-jian, thanks so much for noting and flagging all of this!
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.

2 participants