public class FisherExact
This does a Fisher Exact test. The Fisher's Exact test procedure calculates an exact probability value for the relationship between two dichotomous variables, as found in a two by two crosstable. The program calculates the difference between the data observed and the data expected, considering the given marginal and the assumptions of the model of independence. It works in exactly the same way as the Chi-square test for independence; however, the Chi-square gives only an estimate of the true probability value, an estimate which might not be very accurate if the marginal is very uneven or if there is a small value (less than five) in one of the cells. It uses an array of factorials initialized at the beginning to provide speed. There could be better ways to do this.
public static FisherExact getInstance(int size)
Static method to get instance
public double getP(int a,
int b,
int c,
int d)
calculates the P-value for this specific state
a - a, b, c, d are the four cells in a 2x2 matrixb - c - d - public double getCumlativeP(int a,
int b,
int c,
int d)
Calculates the one-tail P-value for the Fisher Exact test. Determines whether to calculate the right- or left- tail, thereby always returning the smallest p-value.
a - a, b, c, d are the four cells in a 2x2 matrixb - c - d - public double getRightTailedP(int a,
int b,
int c,
int d)
Calculates the right-tail P-value for the Fisher Exact test.
a - a, b, c, d are the four cells in a 2x2 matrixb - c - d - public double getRightTailedPQuick(int a,
int b,
int c,
int d,
double maxP)
Calculates the right-tail P-value for the Fisher Exact test.
a - a, b, c, d are the four cells in a 2x2 matrixb - c - d - public double getLeftTailedP(int a,
int b,
int c,
int d)
Calculates the left-tail P-value for the Fisher Exact test.
a - a, b, c, d are the four cells in a 2x2 matrixb - c - d - public double getTwoTailedP(int a,
int b,
int c,
int d)
Calculates the two-tailed P-value for the Fisher Exact test. In order for a table under consideration to have its p-value included in the final result, it must have a p-value less than the original table's P-value, i.e. Fisher's exact test computes the probability, given the observed marginal frequencies, of obtaining exactly the frequencies observed and any configuration more extreme. By "more extreme," we mean any configuration (given observed marginals) with a smaller probability of occurrence in the same direction (one-tailed) or in both directions (two-tailed).
a - a, b, c, d are the four cells in a 2x2 matrixb - c - d -