-
Notifications
You must be signed in to change notification settings - Fork 589
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
avoid error due to finite precision error in M2 pon creation #5797
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5797 +/- ##
===============================================
- Coverage 87.005% 86.997% -0.008%
- Complexity 32097 32112 +15
===============================================
Files 1974 1974
Lines 147213 147249 +36
Branches 16214 16218 +4
===============================================
+ Hits 128082 128102 +20
- Misses 13228 13239 +11
- Partials 5903 5908 +5
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have already addressed values greater than 1, feel free to merge. Otherwise, please address that and I can re-review.
final double hetPrior = alleleFrequency * (1 - alleleFrequency) * 2; | ||
final double homPrior = MathUtils.square(alleleFrequency); | ||
final double hetLikelihood = MathUtils.binomialProbability(totalCount, altCount, 0.5); | ||
final double homLikelihood = MathUtils.binomialProbability(totalCount, altCount, 0.98); | ||
|
||
final double artifactLikelihood = new BetaBinomialDistribution(null, ARTIFACT_ALPHA, ARTIFACT_BETA, totalCount).probability(altCount); | ||
|
||
return MathUtils.normalizeFromRealSpace(new double[] {hetPrior * hetLikelihood + homPrior * homLikelihood, ARTIFACT_PRIOR * artifactLikelihood})[0]; | ||
final double[] relativeProbsOfHetHomArtifact = {hetPrior * hetLikelihood + homPrior * homLikelihood, ARTIFACT_PRIOR * artifactLikelihood}; | ||
if (MathUtils.sum(relativeProbsOfHetHomArtifact) < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return max(..., 0);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (MathUtils.sum(relativeProbsOfHetHomArtifact) < 0) { | ||
return 0; | ||
} | ||
return MathUtils.normalizeFromRealSpace(relativeProbsOfHetHomArtifact)[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indices look like they have special meaning. Can you describe, in a comment, the meaning of the values in [0] and [1]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@LeeTL1220 for the REBC pon.