edu.uah.math.distributions
Class HypergeometricDistribution

java.lang.Object
  extended by edu.uah.math.distributions.Distribution
      extended by edu.uah.math.distributions.HypergeometricDistribution
All Implemented Interfaces:
java.io.Serializable

public class HypergeometricDistribution
extends Distribution
implements java.io.Serializable

This class models the hypergeometric distribution with a specified population size, sample size, and number of type 1 objects. This is the distribution of the number of type 1 objects in a sample chosen without replacement from a finite, two-type population.

Version:
August, 2003
Author:
Kyle Siegrist, Dawn Duehring
See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.uah.math.distributions.Distribution
CONTINUOUS, DISCRETE, MIXED
 
Constructor Summary
HypergeometricDistribution()
          This default constructor: creates a new hypergeometric distribuiton with population 100 containing 50 type 1 objects, and with sample size 10.
HypergeometricDistribution(int m, int r, int n)
          This general constructor creates a new hypergeometric distribution with specified values of the parameters.
 
Method Summary
 double getDensity(double x)
          This method computes the probability density function.
 double getMaxDensity()
          This method computes the aximum value of the probability density function.
 double getMean()
          This method computes the mean of the distribution, which is n r / m.
 int getPopulationSize()
          This method gets the population size.
 int getSampleSize()
          This method gets the sample size.
 int getType1Size()
          This method gets the number of type 1 elements.
 double getVariance()
          This method computes the variance, which is given by n (r/m) (1 − r/m)(m − n) / (m − 1).
 void setParameters(int m, int r, int n)
          This method set the parameters of the distribution and computes the domain.
 void setPopulationSize(int m)
          This method sets population size.
 void setSampleSize(int n)
          This method sets the sample size.
 void setType1Size(int r)
          This method sets the number of type 1 elements
 double simulate()
          This method simulate a value from the distribution.
 java.lang.String toString()
          This method returns a string that gives the name of the distribution and the values of the parameters.
 
Methods inherited from class edu.uah.math.distributions.Distribution
getCDF, getDomain, getFailureRate, getMedian, getMGF, getMoment, getMoment, getPGF, getQuantile, getSD, getType, setDomain, setDomain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HypergeometricDistribution

public HypergeometricDistribution(int m,
                                  int r,
                                  int n)
This general constructor creates a new hypergeometric distribution with specified values of the parameters.

Parameters:
m - the population size
r - the number of type 1 objects in the population
n - the sample size

HypergeometricDistribution

public HypergeometricDistribution()
This default constructor: creates a new hypergeometric distribuiton with population 100 containing 50 type 1 objects, and with sample size 10.

Method Detail

setParameters

public void setParameters(int m,
                          int r,
                          int n)
This method set the parameters of the distribution and computes the domain.

Parameters:
m - the population size
r - the number of type 1 objects
n - the sample size

getDensity

public double getDensity(double x)
This method computes the probability density function. The PDF is f(x) = C(r, x) C(m − r, n − x) / C(m, n).

Specified by:
getDensity in class Distribution
Parameters:
x - an integer between 0 and the sample size
Returns:
the probability density at x

getMaxDensity

public double getMaxDensity()
This method computes the aximum value of the probability density function. The mode occurs at (n + 1)(r + 1)/(m + 2).

Overrides:
getMaxDensity in class Distribution
Returns:
the maximum value of the probability density function

getMean

public double getMean()
This method computes the mean of the distribution, which is n r / m.

Overrides:
getMean in class Distribution
Returns:
the mean

getVariance

public double getVariance()
This method computes the variance, which is given by n (r/m) (1 − r/m)(m − n) / (m − 1).

Overrides:
getVariance in class Distribution
Returns:
the variance

setPopulationSize

public void setPopulationSize(int m)
This method sets population size.

Parameters:
m - the population size

getPopulationSize

public int getPopulationSize()
This method gets the population size.

Returns:
the population size

setType1Size

public void setType1Size(int r)
This method sets the number of type 1 elements

Parameters:
r - the number of type 1 elements

getType1Size

public int getType1Size()
This method gets the number of type 1 elements.

Returns:
the number of type 1 elements

setSampleSize

public void setSampleSize(int n)
This method sets the sample size.

Parameters:
n - the sample size

getSampleSize

public int getSampleSize()
This method gets the sample size.

Returns:
the sample size

simulate

public double simulate()
This method simulate a value from the distribution. This is done by simulating a sample of size n without replacment from the population {1, 2, ..., m} and counting the number of elemets less than r.

Overrides:
simulate in class Distribution
Returns:
a simulated value from the distribution

toString

public java.lang.String toString()
This method returns a string that gives the name of the distribution and the values of the parameters.

Overrides:
toString in class Distribution
Returns:
a string giving the name of the distribution and the values of the parameters