Class HypergeometricDistributionImpl
java.lang.Object
org.apache.commons.math.distribution.AbstractDistribution
org.apache.commons.math.distribution.AbstractIntegerDistribution
org.apache.commons.math.distribution.HypergeometricDistributionImpl
- All Implemented Interfaces:
Serializable,DiscreteDistribution,Distribution,HypergeometricDistribution,IntegerDistribution
public class HypergeometricDistributionImpl
extends AbstractIntegerDistribution
implements HypergeometricDistribution, Serializable
The default implementation of
HypergeometricDistribution.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionHypergeometricDistributionImpl(int populationSize, int numberOfSuccesses, int sampleSize) Construct a new hypergeometric distribution with the given the population size, the number of successes in the population, and the sample size. -
Method Summary
Modifier and TypeMethodDescriptiondoublecumulativeProbability(int x) For this distribution, X, this method returns P(X ≤ x).intAccess the number of successes.doubleReturns the variance.intAccess the population size.intAccess the sample size.intReturns the lower bound for the support for the distribution.intReturns the upper bound for the support of the distribution.doubleprobability(int x) For this distribution, X, this method returns P(X = x).voidsetNumberOfSuccesses(int num) Deprecated.as of 2.1 (class will become immutable in 3.0)voidsetPopulationSize(int size) Deprecated.as of 2.1 (class will become immutable in 3.0)voidsetSampleSize(int size) Deprecated.as of 2.1 (class will become immutable in 3.0)doubleupperCumulativeProbability(int x) For this distribution, X, this method returns P(X ≥ x).Methods inherited from class org.apache.commons.math.distribution.AbstractIntegerDistribution
cumulativeProbability, cumulativeProbability, cumulativeProbability, inverseCumulativeProbability, isSupportLowerBoundInclusive, isSupportUpperBoundInclusive, probability, reseedRandomGenerator, sample, sampleMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.math.distribution.DiscreteDistribution
probabilityMethods inherited from interface org.apache.commons.math.distribution.Distribution
cumulativeProbability, cumulativeProbabilityMethods inherited from interface org.apache.commons.math.distribution.IntegerDistribution
cumulativeProbability, inverseCumulativeProbability
-
Constructor Details
-
HypergeometricDistributionImpl
public HypergeometricDistributionImpl(int populationSize, int numberOfSuccesses, int sampleSize) Construct a new hypergeometric distribution with the given the population size, the number of successes in the population, and the sample size.- Parameters:
populationSize- the population size.numberOfSuccesses- number of successes in the population.sampleSize- the sample size.
-
-
Method Details
-
cumulativeProbability
public double cumulativeProbability(int x) For this distribution, X, this method returns P(X ≤ x).- Specified by:
cumulativeProbabilityin interfaceIntegerDistribution- Specified by:
cumulativeProbabilityin classAbstractIntegerDistribution- Parameters:
x- the value at which the PDF is evaluated.- Returns:
- PDF for this distribution.
-
getNumberOfSuccesses
public int getNumberOfSuccesses()Access the number of successes.- Specified by:
getNumberOfSuccessesin interfaceHypergeometricDistribution- Returns:
- the number of successes.
-
getPopulationSize
public int getPopulationSize()Access the population size.- Specified by:
getPopulationSizein interfaceHypergeometricDistribution- Returns:
- the population size.
-
getSampleSize
public int getSampleSize()Access the sample size.- Specified by:
getSampleSizein interfaceHypergeometricDistribution- Returns:
- the sample size.
-
probability
public double probability(int x) For this distribution, X, this method returns P(X = x).- Specified by:
probabilityin interfaceIntegerDistribution- Parameters:
x- the value at which the PMF is evaluated.- Returns:
- PMF for this distribution.
-
setNumberOfSuccesses
Deprecated.as of 2.1 (class will become immutable in 3.0)Modify the number of successes.- Specified by:
setNumberOfSuccessesin interfaceHypergeometricDistribution- Parameters:
num- the new number of successes.- Throws:
IllegalArgumentException- ifnumis negative.
-
setPopulationSize
Deprecated.as of 2.1 (class will become immutable in 3.0)Modify the population size.- Specified by:
setPopulationSizein interfaceHypergeometricDistribution- Parameters:
size- the new population size.- Throws:
IllegalArgumentException- ifsizeis not positive.
-
setSampleSize
Deprecated.as of 2.1 (class will become immutable in 3.0)Modify the sample size.- Specified by:
setSampleSizein interfaceHypergeometricDistribution- Parameters:
size- the new sample size.- Throws:
IllegalArgumentException- ifsizeis negative.
-
upperCumulativeProbability
public double upperCumulativeProbability(int x) For this distribution, X, this method returns P(X ≥ x).- Parameters:
x- the value at which the CDF is evaluated.- Returns:
- upper tail CDF for this distribution.
- Since:
- 1.1
-
getSupportLowerBound
public int getSupportLowerBound()Returns the lower bound for the support for the distribution. For population sizeN, number of successesm, and sample sizen, the lower bound of the support ismax(0, n + m - N)- Returns:
- lower bound of the support
- Since:
- 2.2
-
getSupportUpperBound
public int getSupportUpperBound()Returns the upper bound for the support of the distribution. For number of successesmand sample sizen, the upper bound of the support ismin(m, n)- Returns:
- upper bound of the support
- Since:
- 2.2
-
getNumericalVariance
public double getNumericalVariance()Returns the variance. For population sizeN, number of successesm, and sample sizen, the variance is[ n * m * (N - n) * (N - m) ] / [ N^2 * (N - 1) ]- Returns:
- the variance
- Since:
- 2.2
-