Generate a pseudorandom number from a hypergeometric distribution.
int
which specifies the number of items in the sample, . int
which specifies the number of special items in the population, or lot, . int
which specifies the number of items in the lot, . A int
which specifies the number of special items in a sample of size n drawn without replacement from a population of size l that contains m such special items.
Method NextHypergeometric
generates pseudorandom numbers from a hypergeometric distribution with parameters n, m, and l. The hypergeometric random variable x can be thought of as the number of items of a given type in a random sample of size n that is drawn without replacement from a population of size l containing m items of this type. The probability function is
for .
If the hypergeometric probability function with parameters n, m, and l evaluated at n - l + m (or at 0 if this is negative) is greater than the machine epsilon, and less than 1.0 minus the machine epsilon, then NextHypergeometric
uses the inverse CDF technique. The method recursively computes the hypergeometric probabilities, starting at and using the ratio f (x = x + 1)/f(x = x) (see Fishman 1978, page 457).
If the hypergeometric probability function is too small or too close to 1.0, then NextHypergeometric
generates integer deviates uniformly in the interval , for ; and at the I-th step, if the generated deviate is less than or equal to the number of special items remaining in the lot, the occurrence of one special item is tallied and the number of remaining special items is decreased by one. This process continues until the sample size or the number of special items in the lot is reached, whichever comes first. This method can be much slower than the inverse CDF technique. The timing depends on n. If n is more than half of l (which in practical examples is rarely the case), the user may wish to modify the problem, replacing n by l - n, and to consider the deviates to be the number of special items not included in the sample.
Random Class | Imsl.Stat Namespace | Example