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

Use StrictMath to get same results on different CPU architectures #596

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/au/edu/wehi/idsv/util/MathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

public class MathUtil {
public static double phredToPr(double phred) {
return Math.pow(10, -phred / 10);
return StrictMath.pow(10, -phred / 10);
}
public static double prToPhred(double pr) {
if (pr == 0) return 0;
return -10 * Math.log10(pr);
return -10 * StrictMath.log10(pr);
}
/**
* Returns the phred-scaled error probability of no
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/au/edu/wehi/idsv/util/MathUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void phredOr_should_be_exact_for_single_score() {
@Test
public void phredOr_should_minimise_error() {
// http://www.wolframalpha.com/input/?i=-10+*+%28log%2810%2C+1+-+%281+-+10%5E%28-5%2F10%29%29+*+%281+-+10%5E%28-5%2F10%29%29%29+%29
assertEquals(2.737166564315747414571566754814524996985593328024647081266066, MathUtil.phredOr(5, 5), 0);
assertEquals(2.737166564315747, MathUtil.phredOr(5, 5), 0);
assertEquals(4.999906094489629897297010515927232501782840270893945897373360, MathUtil.phredOr(5, 50), 0);
assertEquals(0.999998875501369913289357102130159464124571763746365284402279, MathUtil.phredOr(1, 60), 0);
assertEquals(0.99999999988755012243472182763604174153706462136143019889429, MathUtil.phredOr(1, 100), 0.000000000000001);
Expand Down