hypergeometricPdf

Evaluates the hypergeometric probability function.

Synopsis

hypergeometricPdf (k, n, m, l)

Required Arguments

int k (Input)
Argument for which the hypergeometric probability function is to be evaluated.
int n (Input)
Sample size. n must be greater than zero and greater than or equal to k.
int m (Input)
Number of defectives in the lot.
int l (Input)
Lot size. l must be greater than or equal to n and m.

Return Value

The probability that a hypergeometric random variable takes a value equal to k. This value is the probability that exactly k defectives occur in a sample of size n drawn from a lot of size l that contains m defectives.

Description

The function hypergeometicPdf evaluates the probability function of a hypergeometric random variable with parameters n, l, and m. 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

\[f(k|n,m,l) = \Pr(X=k) = \tfrac{\left( _k^m \right)\left( _{n-k}^{l-m} \right)}{\left( _n^l \right)} \text{ for } k = i,i+1,i+2, \ldots \min(n,m)\]

where

\[\binom{m}{k} = \frac{m!}{k!(n-k)!}\]

and

\[i = \max(0,n-l+m).\]

hypergeometicPdf evaluates the expression using log gamma functions.

Example

Suppose X is a hypergeometric random variable with \(n=100\), \(l=1000\), and \(m=70\). In this example, we evaluate the probability function at 7.

from __future__ import print_function
from numpy import *
from pyimsl.stat.hypergeometricPdf import hypergeometricPdf

k = 7
l = 1000
m = 70
n = 100
pr = hypergeometricPdf(k, n, m, l)
print("The probability that X is equal to 7 is %6.4f" % pr)

Output

The probability that X is equal to 7 is 0.1628