edu.northwestern.at.utils.math.statistics
Class FishersExactTest

java.lang.Object
  extended by edu.northwestern.at.utils.math.statistics.FishersExactTest

public class FishersExactTest
extends java.lang.Object

Calculate Fisher's exact test for a 2x2 frequency table.


Constructor Summary
protected FishersExactTest()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static double[] fishersExactTest(int n11, int n12, int n21, int n22)
          Calculate Fisher's exact test from the four cell counts.
protected static double hypergeometricProbability(int x, int n1d, int n2d, int nd1, int nd2)
          Compute hypergeometric probability.
protected static double logCombination(int n, int k)
          Compute log of number of combinations of n things taken k at a time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FishersExactTest

protected FishersExactTest()
Don't allow instantiation but do allow overrides.

Method Detail

fishersExactTest

public static double[] fishersExactTest(int n11,
                                        int n12,
                                        int n21,
                                        int n22)
Calculate Fisher's exact test from the four cell counts.

Parameters:
n11 - Frequency for cell(1,1).
n12 - Frequency for cell(1,2).
n21 - Frequency for cell(2,1).
n22 - Frequency for cell(2,2).
Returns:
double vector with three entries. [0] = two-sided Fisher's exact test. [1] = left-tail Fisher's exact test. [2] = right-tail Fisher's exact test.

logCombination

protected static double logCombination(int n,
                                       int k)
Compute log of number of combinations of n things taken k at a time.

Parameters:
n - Number of items.
k - Group size.
Returns:
Value for log of n items taken k at a time.

log(combination(n,m)) = log(n!/m!(n-m)!) = log(n!) - log(m!) - log((n-m)!)


hypergeometricProbability

protected static double hypergeometricProbability(int x,
                                                  int n1d,
                                                  int n2d,
                                                  int nd1,
                                                  int nd2)
Compute hypergeometric probability.

Parameters:
x -
n1d -
n2d -
nd1 -
nd2 -
Returns:
The hypergeometric probability.