procope.tools.math
Class HypergeometricDistribution
java.lang.Object
procope.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
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 |
HypergeometricDistribution
public HypergeometricDistribution()
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 drawnwhiteBalls
- number of white balls in the urnblackBalls
- number of black balls in the urndrawings
- number of drawings to be madelower_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 drawnwhiteBalls
- number of white balls in the urnblackBalls
- number of black balls in the urndrawings
- number of drawings to be made
- Returns:
- logarithmic probability to draw
hits
white balls