SSJ
V. 2.6.

umontreal.iro.lecuyer.probdist
Class HypergeometricDist

java.lang.Object
  extended by umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
      extended by umontreal.iro.lecuyer.probdist.HypergeometricDist
All Implemented Interfaces:
Distribution

public class HypergeometricDist
extends DiscreteDistributionInt

Extends the class DiscreteDistributionInt for 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 by

p(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 in BinomialDist.


Field Summary
static double MAXN
           
 
Fields inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
EPSILON
 
Constructor Summary
HypergeometricDist(int m, int l, int k)
          Constructs an hypergeometric distribution with parameters m, l and k.
 
Method Summary
 double barF(int x)
          Returns bar(F)(x), the complementary distribution function.
static double barF(int m, int l, int k, int x)
          Computes the complementary distribution function.
 double cdf(int x)
          Returns the distribution function F evaluated at x (see).
static double cdf(int m, int l, int k, int x)
          Computes the distribution function F(x).
 int getK()
          Returns the k associated with this object.
 int getL()
          Returns the l associated with this object.
 int getM()
          Returns the m associated with this object.
 double getMean()
          Returns the mean of the distribution function.
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.
 double[] getParams()
          Return a table containing the parameters of the current distribution.
 double getStandardDeviation()
          Returns the standard deviation of the distribution function.
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.
 double getVariance()
          Returns the variance of the distribution function.
static double getVariance(int m, int l, int k)
          Computes and returns the variance of the hypergeometric distribution with parameters m, l and k.
static int inverseF(int m, int l, int k, double u)
          Computes F-1(u) for the hypergeometric distribution without using precomputed tables.
 int inverseFInt(double u)
          Returns the inverse distribution function F-1(u), where 0 <= u <= 1.
 double prob(int x)
          Returns p(x), the probability of x.
static double prob(int m, int l, int k, int x)
          Computes the hypergeometric probability p(x).
 void setParams(int m, int l, int k)
          Resets the parameters of this object to m, l and k.
 String toString()
           
 
Methods inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
barF, cdf, getXinf, getXsup, inverseF
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAXN

public static double MAXN
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: DiscreteDistributionInt
Returns p(x), the probability of x.

Specified by:
prob in class DiscreteDistributionInt
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: DiscreteDistributionInt
Returns the distribution function F evaluated at x (see).

Specified by:
cdf in class DiscreteDistributionInt
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: DiscreteDistributionInt
Returns bar(F)(x), the complementary distribution function. See the WARNING above.

Overrides:
barF in class DiscreteDistributionInt
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: DiscreteDistributionInt
Returns the inverse distribution function F-1(u), where 0 <= u <= 1. The default implementation uses binary search.

Overrides:
inverseFInt in class DiscreteDistributionInt
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: Distribution
Returns the mean of the distribution function.


getVariance

public double getVariance()
Description copied from interface: Distribution
Returns the variance of the distribution function.


getStandardDeviation

public double getStandardDeviation()
Description copied from interface: Distribution
Returns 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 String toString()
Overrides:
toString in class Object

SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.