StatsFunctions provides the FisherEactTest() method for performing a Fisher's Exact Test for a specified 2 x 2 contingency table. Fisher's Exact Test is a useful alternative to the chi-square test in cases where sample sizes are small.
Fisher's Exact Test is so-called because the significance of the deviation from a null hypothesis can be calculated exactly, rather than relying on an approximation. The usual rule of thumb for deciding whether the chi-squared approximation is good enough is whether the expected values in all cells of the contingency table is greater than or equal to 5.
You can perform a Fisher's Exact Test by providing the cell values directly, plus an HypothesisType specifying the form of the alternative hypothesis:
Code Example – C# Fisher's exact test
int a = 12, b = 17, c = 4, d = 25;
double pvalue = StatsFunctions.FishersExactTest( a, b, c, d,
Code Example – VB Fisher's exact test
Dim A As Integer = 12
Dim B As Integer = 17
Dim C As Integer = 4
Dim D As Integer = 25
Dim PValue As Double = StatsFunctions.FishersExactTest(A, B, C, D, HypothesisType.TwoSided)
Values a, b, c and d are cell counts for contingency table:
If no hypothesis type is specified, FisherExactTest() returns the lesser of the right and left tail p-value.