hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_stat_prob_hypergeom (g01bl)

Purpose

nag_stat_prob_hypergeom (g01bl) returns the lower tail, upper tail and point probabilities associated with a hypergeometric distribution.

Syntax

[plek, pgtk, peqk, ifail] = g01bl(n, l, m, k)
[plek, pgtk, peqk, ifail] = nag_stat_prob_hypergeom(n, l, m, k)

Description

Let XX denote a random variable having a hypergeometric distribution with parameters nn, ll and mm (nl0nl0, nm0nm0). Then
Prob{X = k} =
(m) k (n − m) l − k
(n) l ,
Prob{X=k}= m k n-m l-k n l ,
where max (0,l(nm)) k min (l,m) max(0,l-(n-m)) k min(l,m) , 0ln0ln and 0mn0mn.
The hypergeometric distribution may arise if in a population of size nn a number mm are marked. From this population a sample of size ll is drawn and of these kk are observed to be marked.
The mean of the distribution = (lm)/n = lm n , and the variance = (lm(nl)(nm))/(n2(n1)) = lm(n-l)(n-m) n2(n-1) .
nag_stat_prob_hypergeom (g01bl) computes for given nn, ll, mm and kk the probabilities:
plek = Prob{Xk}
pgtk = Prob{X > k}
peqk = Prob{X = k} .
plek=Prob{Xk} pgtk=Prob{X>k} peqk=Prob{X=k} .
The method is similar to the method for the Poisson distribution described in Knüsel (1986).

References

Knüsel L (1986) Computation of the chi-square and Poisson distribution SIAM J. Sci. Statist. Comput. 7 1022–1036

Parameters

Compulsory Input Parameters

1:     n – int64int32nag_int scalar
The parameter nn of the hypergeometric distribution.
Constraint: n0n0.
2:     l – int64int32nag_int scalar
The parameter ll of the hypergeometric distribution.
Constraint: 0ln0ln.
3:     m – int64int32nag_int scalar
The parameter mm of the hypergeometric distribution.
Constraint: 0mn0mn.
4:     k – int64int32nag_int scalar
The integer kk which defines the required probabilities.
Constraint: max (0,l(nm))kmin (l,m)max(0,l-(n-m))kmin(l,m).

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     plek – double scalar
The lower tail probability, Prob{Xk}Prob{Xk}.
2:     pgtk – double scalar
The upper tail probability, Prob{X > k}Prob{X>k}.
3:     peqk – double scalar
The point probability, Prob{X = k}Prob{X=k}.
4:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n < 0n<0.
  ifail = 2ifail=2
On entry,l < 0l<0,
orl > nl>n.
  ifail = 3ifail=3
On entry,m < 0m<0,
orm > nm>n.
  ifail = 4ifail=4
On entry,k < 0k<0,
ork > lk>l,
ork > mk>m,
ork < l + mnk<l+m-n.
  ifail = 5ifail=5
On entry,n is too large to be represented exactly as a double number.
  ifail = 6ifail=6
On entry,the variance (see Section [Description]) exceeds 106106.

Accuracy

Results are correct to a relative accuracy of at least 10610-6 on machines with a precision of 99 or more decimal digits, and to a relative accuracy of at least 10310-3 on machines of lower precision (provided that the results do not underflow to zero).

Further Comments

The time taken by nag_stat_prob_hypergeom (g01bl) depends on the variance (see Section [Description]) and on kk. For given variance, the time is greatest when klm / nklm/n ( = = the mean), and is then approximately proportional to the square-root of the variance.

Example

function nag_stat_prob_hypergeom_example
n = int64(10);
l = int64(2);
m = int64(5);
k = int64(1);
[plek, pgtk, peqk, ifail] = nag_stat_prob_hypergeom(n, l, m, k)
 

plek =

    0.7778


pgtk =

    0.2222


peqk =

    0.5556


ifail =

                    0


function g01bl_example
n = int64(10);
l = int64(2);
m = int64(5);
k = int64(1);
[plek, pgtk, peqk, ifail] = g01bl(n, l, m, k)
 

plek =

    0.7778


pgtk =

    0.2222


peqk =

    0.5556


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013