umontreal.iro.lecuyer.probdist
Class HypergeometricDist
- java.lang.Object
-
- umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
-
- umontreal.iro.lecuyer.probdist.HypergeometricDist
-
- All Implemented Interfaces:
- Distribution
public class HypergeometricDist extends DiscreteDistributionInt
Extends the classDiscreteDistributionIntfor the hypergeometric distribution with k elements chosen among l, m being of one type, and l - m of the other. The parameters m, k and l are positive integers where 1 <= m <= l and 1 <= k <= l. Its mass function is given byp(x) = nCr(m, x)nCr(l - m, k - x)/nCr(l, k), for max(0, k - l + m) <= x <= min(k, m),where nCr is defined inBinomialDist.
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleMAXN-
Fields inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
EPSILON
-
-
Constructor Summary
Constructors Constructor and Description HypergeometricDist(int m, int l, int k)Constructs an hypergeometric distribution with parameters m, l and k.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublebarF(int x)Returns bar(F)(x), the complementary distribution function.static doublebarF(int m, int l, int k, int x)Computes the complementary distribution function.doublecdf(int x)Returns the distribution function F evaluated at x (see).static doublecdf(int m, int l, int k, int x)Computes the distribution function F(x).intgetK()Returns the k associated with this object.intgetL()Returns the l associated with this object.intgetM()Returns the m associated with this object.doublegetMean()Returns the mean of the distribution function.static doublegetMean(int m, int l, int k)Computes and returns the mean E[X] = km/l of the Hypergeometric distribution with parameters m, l and k.double[]getParams()Return a table containing the parameters of the current distribution.doublegetStandardDeviation()Returns the standard deviation of the distribution function.static doublegetStandardDeviation(int m, int l, int k)Computes and returns the standard deviation of the hypergeometric distribution with parameters m, l and k.doublegetVariance()Returns the variance of the distribution function.static doublegetVariance(int m, int l, int k)Computes and returns the variance of the hypergeometric distribution with parameters m, l and k.static intinverseF(int m, int l, int k, double u)Computes F-1(u) for the hypergeometric distribution without using precomputed tables.intinverseFInt(double u)Returns the inverse distribution function F-1(u), where 0 <= u <= 1.doubleprob(int x)Returns p(x), the probability of x, which should be a real number in the interval [0, 1].static doubleprob(int m, int l, int k, int x)Computes the hypergeometric probability p(x).voidsetParams(int m, int l, int k)Resets the parameters of this object to m, l and k.java.lang.StringtoString()
-
-
-
Constructor Detail
-
HypergeometricDist
public HypergeometricDist(int m, int l, int k)Constructs an hypergeometric distribution with parameters m, l and k.
-
-
Method Detail
-
prob
public double prob(int x)
Description copied from class:DiscreteDistributionIntReturns p(x), the probability of x, which should be a real number in the interval [0, 1].- Specified by:
probin classDiscreteDistributionInt- Parameters:
x- value at which the mass function must be evaluated- Returns:
- the mass function evaluated at x
-
cdf
public double cdf(int x)
Description copied from class:DiscreteDistributionIntReturns the distribution function F evaluated at x (see).- Specified by:
cdfin classDiscreteDistributionInt- Parameters:
x- value at which the distribution function must be evaluated- Returns:
- the distribution function evaluated at x
-
barF
public double barF(int x)
Description copied from class:DiscreteDistributionIntReturns bar(F)(x), the complementary distribution function. See the WARNING above.- Overrides:
barFin classDiscreteDistributionInt- Parameters:
x- value at which the complementary distribution function must be evaluated- Returns:
- the complementary distribution function evaluated at x
-
inverseFInt
public int inverseFInt(double u)
Description copied from class:DiscreteDistributionIntReturns the inverse distribution function F-1(u), where 0 <= u <= 1. The default implementation uses binary search.- Overrides:
inverseFIntin classDiscreteDistributionInt- Parameters:
u- value in the interval (0, 1) for which the inverse distribution function is evaluated- Returns:
- the inverse distribution function evaluated at u
-
getMean
public double getMean()
Description copied from interface:DistributionReturns the mean of the distribution function.
-
getVariance
public double getVariance()
Description copied from interface:DistributionReturns the variance of the distribution function.
-
getStandardDeviation
public double getStandardDeviation()
Description copied from interface:DistributionReturns the standard deviation of the distribution function.
-
prob
public static double prob(int m, int l, int k, int x)Computes the hypergeometric probability p(x).
-
cdf
public static double cdf(int m, int l, int k, int x)Computes the distribution function F(x).
-
barF
public static double barF(int m, int l, int k, int x)Computes the complementary distribution function. WARNING: The complementary distribution function is defined as bar(F)(x) = P[X >= x].
-
inverseF
public static int inverseF(int m, int l, int k, double u)Computes F-1(u) for the hypergeometric distribution without using precomputed tables. The inversion is computed using the chop-down algorithm.
-
getMean
public static double getMean(int m, int l, int k)Computes and returns the mean E[X] = km/l of the Hypergeometric distribution with parameters m, l and k.- Returns:
- the mean of the hypergeometric distribution E[X] = km/l
-
getVariance
public static double getVariance(int m, int l, int k)Computes and returns the variance of the hypergeometric distribution with parameters m, l and k.- Returns:
- the variance of the Hypergeometric distribution Var[X] = (km/l )(1 - m/l )(l - k)/(l - 1)
-
getStandardDeviation
public static double getStandardDeviation(int m, int l, int k)Computes and returns the standard deviation of the hypergeometric distribution with parameters m, l and k.- Returns:
- the standard deviation of the hypergeometric distribution
-
getM
public int getM()
Returns the m associated with this object.
-
getL
public int getL()
Returns the l associated with this object.
-
getK
public int getK()
Returns the k associated with this object.
-
getParams
public double[] getParams()
Return a table containing the parameters of the current distribution. This table is put in regular order: [m, l, k].
-
setParams
public void setParams(int m, int l, int k)Resets the parameters of this object to m, l and k.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG