fisherExact - multiple declarations
Function fisherExact
Fisher's Exact test for difference in odds between rows/columns in a 2x2 contingency table. Specifically, this function tests the odds ratio, which is defined, for a contingency table c, as (c[0][0] * c[1][1]) / (c[1][0] * c[0][1]). Alternatives are Alt.less, meaning true odds ratio < 1, Alt.greater, meaning true odds ratio > 1, and Alt.twoSided, meaning true odds ratio != 1.
Accepts a 2x2 contingency table as an array of arrays of uints. For now, only does 2x2 contingency tables.
Notes
Although this test is "exact" in that it does not rely on asymptotic approximations, it is very statistically conservative when the marginals are not truly fixed in the experimental design in question. If a closer but possibly non-conservative approximation of the true P-value is desired, Pearson's chi-square test (chiSquareContingency) may perform better, even for small samples.
Returns
A TestRes of the odds ratio and the P-value against the given alternative.
Examples
double res = fisherExact([[2u, 7], [8, 2]], Alt .less);
assert(approxEqual(res .p, 0.01852)); // Odds ratio is very small in this case.
assert(approxEqual(res .testStat, 4.0 / 56.0));
References
http://en.wikipedia.org/wiki/Fisher%27s_Exact_Test
Function fisherExact
Convenience function. Converts a dynamic array to a static one, then calls the overload.