Class Hypergeometric

java.lang.Object
org.snpeff.probablility.Hypergeometric

public class Hypergeometric extends Object
Calculate hypergeometric distribution using an optimized algorithm that avoids problems with big factorials. Also calculated Fisher's exact test In general everything is expressed in a 2x2 'contingency' table form sequence of 'n' draws from a finite population without replacement drawn not drawn | total defective k D - k | D nondefective n - k N + k - n - D | N - D ----------------------------+---------- total n N - n | N This can be viewed as if we have a bag of N marbles having D white marbles, and we take a sample of n marbles(without replacement) N : Total marbles D : White marbles => N-D : Black marbles n : marbles drawn => N-n : not drawn k : white marbles drawn
Author:
pcingola
  • Field Details

    • EPSILON

      public static double EPSILON
      A small number
  • Method Details

    • get

      public static Hypergeometric get()
    • main

      public static void main(String[] args)
    • checkHypergeometricParams

      public boolean checkHypergeometricParams(int k, int N, int D, int n)
      Check if hypergeometric paramters are correct
      Parameters:
      k -
      N -
      D -
      n -
      Returns:
    • hypergeometric

      public double hypergeometric(int k, int N, int D, int n)
      See http://en.wikipedia.org/wiki/Hypergeometric_distribution
      Parameters:
      k - : white marbles drawn
      N - : Total marbles
      D - : White marbles => N-D : Black marbles
      n - : marbles drawn => N-n : not drawn
      Returns:
      Hypergeometric distribution References: http://en.wikipedia.org/wiki/Fisher%27s_exact_test http://en.wikipedia.org/wiki/Hypergeometric_distribution
    • toR

      public String toR(int k, int N, int D, int n)
      Convert values to 'R' command
      Returns: