tools.math
Class HypergeometricDistribution

java.lang.Object
  extended by tools.math.HypergeometricDistribution

public class HypergeometricDistribution
extends Object

Contains static methods for the rapid calculation of values from the hypergeometric distribution. All functions return logarithms of the respective values. Apply Math.exp(double) to get the real numbers.

Note: To calculate the distribution value of the hypergeometric distribution this implementation uses an approximation found in the source codes of the R Project

Author:
Jan Krumsiek

Constructor Summary
HypergeometricDistribution()
           
 
Method Summary
static double logdhyper(int hits, int whiteBalls, int blackBalls, int drawings)
          Calculates logarithm of a value of the density function.
static double logphyper(int hits, int whiteBalls, int blackBalls, int drawings, boolean lower_tail)
          Calculates logarithm of a value of the cumulative distribution function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HypergeometricDistribution

public HypergeometricDistribution()
Method Detail

logphyper

public static double logphyper(int hits,
                               int whiteBalls,
                               int blackBalls,
                               int drawings,
                               boolean lower_tail)
Calculates logarithm of a value of the cumulative distribution function.

Parameters:
hits - number of white balls to be drawn
whiteBalls - number of white balls in the urn
blackBalls - number of black balls in the urn
drawings - number of drawings to be made
lower_tail - true: probability that <= hits white balls will be drawn; false: probability that > hits white balls will be drawn.
Returns:
logarithmic probability that <= hits or > hits white balls are drawn from the urns

logdhyper

public static double logdhyper(int hits,
                               int whiteBalls,
                               int blackBalls,
                               int drawings)
Calculates logarithm of a value of the density function.

Parameters:
hits - number of white balls to be drawn
whiteBalls - number of white balls in the urn
blackBalls - number of black balls in the urn
drawings - number of drawings to be made
Returns:
logarithmic probability to draw hits white balls