Skip to content

Commit

Permalink
Merge pull request #76 from dpryan79/fix59
Browse files Browse the repository at this point in the history
No CI outside of [0, 1]
  • Loading branch information
dpryan79 authored Apr 13, 2019
2 parents 565484a + 8414d29 commit 25404a9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions svg.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@
//Agresti-Coull confidence interval around a methylation value
//If which is 1, return the upper 99.9% CI, otherwise the return the lower 99.9% CI
double CI(uint32_t um, uint32_t m, int which) {
double ZZ, Z, N_dot, P_dot, X, N;
double ZZ, Z, N_dot, P_dot, X, N, rv;

X = (double) m;
N = (double) (m+um);
ZZ = 10.8275661707; //qnorm(0.9995)^2
Z = 3.2905267315; //qnorm(0.9995)
N_dot = N + ZZ;
P_dot = (1.0/N_dot)*(X+0.5*ZZ);
if(which)
return P_dot + Z*sqrt((P_dot/N_dot)*(1-P_dot));
else
return P_dot - Z*sqrt((P_dot/N_dot)*(1-P_dot));
if(which) {
rv = P_dot + Z*sqrt((P_dot/N_dot)*(1-P_dot));
if(rv>1.) rv = 1.0;
} else {
rv = P_dot - Z*sqrt((P_dot/N_dot)*(1-P_dot));
if(rv<0.) rv = 0.0;
}
return rv;
}

double getMaxY(strandMeth *m) {
Expand Down

0 comments on commit 25404a9

Please sign in to comment.