The two tailed significance is the sum of the one tailed signficance and those point significances which
are greater than P(N = n1)
calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2)
{
int pt;
calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2)
{
int pt;
if (MIN (c, d) < MIN (a, b))
swap (&a, &c), swap (&b, &d);
if (MIN (c, d) < MIN (a, b))
swap (&a, &c), swap (&b, &d);
swap (&a, &c), swap (&b, &d);
}
swap (&a, &c), swap (&b, &d);
}
- *fisher1 = 0.;
- for (pt = 0; pt <= a; pt++)
- *fisher1 += Pr (a - pt, b + pt, c + pt, d - pt);
+ pn1 = Pr (a, b, c, d);
+ *fisher1 = pn1;
+ for (pt = 1; pt <= a; pt++)
+ {
+ *fisher1 += Pr (a - pt, b + pt, c + pt, d - pt);
+ }
for (pt = 1; pt <= b; pt++)
for (pt = 1; pt <= b; pt++)
- *fisher2 += Pr (a + pt, b - pt, c - pt, d + pt);
+ {
+ double p = Pr (a + pt, b - pt, c - pt, d + pt);
+ if (p < pn1)
+ *fisher2 += p;
+ }
}
/* Calculates chi-squares into CHISQ. MAT is a matrix with N_COLS
}
/* Calculates chi-squares into CHISQ. MAT is a matrix with N_COLS