smile.stat.distribution

## Class HyperGeometricDistribution

• All Implemented Interfaces:
java.io.Serializable, Distribution

```public class HyperGeometricDistribution
extends DiscreteDistribution```
The hypergeometric distribution is a discrete probability distribution that describes the number of successes in a sequence of n draws from a finite population without replacement, just as the binomial distribution describes the number of successes for draws with replacement.

Suppose you are to draw "n" balls without replacement from an urn containing "N" balls in total, "m" of which are white. The hypergeometric distribution describes the distribution of the number of white balls drawn from the urn. A random variable X follows the hypergeometric distribution with parameters N, m and n if the probability is given by

```              mCk (N-m)C(n-k)
P(X = k) = ----------------
NCn
```
where nCk is n choose k.
Serialized Form
• ### Field Summary

Fields
Modifier and Type Field and Description
`int` `m`
The number of defects.
`int` `n`
The number of draws.
`int` `N`
The number of total samples.
• ### Constructor Summary

Constructors
Constructor and Description
```HyperGeometricDistribution(int N, int m, int n)```
Constructor.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`double` `cdf(double k)`
Cumulative distribution function.
`double` `entropy()`
Shannon entropy of the distribution.
`int` `length()`
The number of parameters of the distribution.
`double` `logp(int k)`
The probability mass function in log scale.
`double` `mean()`
The mean of distribution.
`double` `p(int k)`
The probability mass function.
`double` `quantile(double p)`
The quantile, the probability to the left of quantile is p.
`double` `rand()`
Uses inversion by chop-down search from the mode when the mean < 20 and the patchwork-rejection method when the mean > 20.
`java.lang.String` `toString()`
`double` `variance()`
The variance of distribution.
• ### Methods inherited from class smile.stat.distribution.DiscreteDistribution

`likelihood, logLikelihood, logp, p, quantile, randi, randi`
• ### Methods inherited from class smile.stat.distribution.AbstractDistribution

`inverseTransformSampling, quantile, quantile, rejection`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface smile.stat.distribution.Distribution

`likelihood, logLikelihood, rand, sd`
• ### Field Detail

• #### N

`public final int N`
The number of total samples.
• #### m

`public final int m`
The number of defects.
• #### n

`public final int n`
The number of draws.
• ### Constructor Detail

• #### HyperGeometricDistribution

```public HyperGeometricDistribution(int N,
int m,
int n)```
Constructor.
Parameters:
`N` - the number of total samples.
`m` - the number of defects.
`n` - the number of draws.
• ### Method Detail

• #### length

`public int length()`
Description copied from interface: `Distribution`
The number of parameters of the distribution. The "length" is in the sense of the minimum description length principle.
• #### mean

`public double mean()`
Description copied from interface: `Distribution`
The mean of distribution.
• #### variance

`public double variance()`
Description copied from interface: `Distribution`
The variance of distribution.
• #### entropy

`public double entropy()`
Description copied from interface: `Distribution`
Shannon entropy of the distribution.
• #### toString

`public java.lang.String toString()`
Overrides:
`toString` in class `java.lang.Object`
• #### p

`public double p(int k)`
Description copied from class: `DiscreteDistribution`
The probability mass function.
Specified by:
`p` in class `DiscreteDistribution`
• #### logp

`public double logp(int k)`
Description copied from class: `DiscreteDistribution`
The probability mass function in log scale.
Specified by:
`logp` in class `DiscreteDistribution`
• #### cdf

`public double cdf(double k)`
Description copied from interface: `Distribution`
Cumulative distribution function. That is the probability to the left of x.
• #### quantile

`public double quantile(double p)`
Description copied from interface: `Distribution`
The quantile, the probability to the left of quantile is p. It is actually the inverse of cdf.
• #### rand

`public double rand()`
Uses inversion by chop-down search from the mode when the mean < 20 and the patchwork-rejection method when the mean > 20.