PDF version (NAG web site
, 64-bit version, 64-bit version)
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
Description
Let
denote a random variable having a hypergeometric distribution with parameters
,
and
(
,
). Then
where
,
and
.
The hypergeometric distribution may arise if in a population of size a number are marked. From this population a sample of size is drawn and of these are observed to be marked.
The mean of the distribution , and the variance .
nag_stat_prob_hypergeom (g01bl) computes for given
,
,
and
the probabilities:
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:
– int64int32nag_int scalar
-
The parameter of the hypergeometric distribution.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
The parameter of the hypergeometric distribution.
Constraint:
.
- 3:
– int64int32nag_int scalar
-
The parameter of the hypergeometric distribution.
Constraint:
.
- 4:
– int64int32nag_int scalar
-
The integer which defines the required probabilities.
Constraint:
.
Optional Input Parameters
None.
Output Parameters
- 1:
– double scalar
-
The lower tail probability, .
- 2:
– double scalar
-
The upper tail probability, .
- 3:
– double scalar
-
The point probability, .
- 4:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
-
-
-
-
-
-
On entry, | , |
or | , |
or | , |
or | . |
-
-
On entry, | n is too large to be represented exactly as a double number. |
-
-
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Results are correct to a relative accuracy of at least on machines with a precision of or more decimal digits, and to a relative accuracy of at least 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
Description) and on
. For given variance, the time is greatest when
(
the mean), and is then approximately proportional to the square-root of the variance.
Example
This example reads values of , , and from a data file until end-of-file is reached, and prints the corresponding probabilities.
Open in the MATLAB editor:
g01bl_example
function g01bl_example
fprintf('g01bl example results\n\n');
n = int64([10 40 155 1000]);
l = int64([ 2 10 35 444]);
m = int64([ 5 3 122 500]);
k = int64([ 1 2 22 220]);
fprintf(' n l m k plek pgtk peqk\n');
for i = 1:4
[plek, pgtk, peqk, ifail] = ...
g01bl(n(i), l(i), m(i), k(i));
fprintf('%5d%4d%4d%4d%10.5f%10.5f%10.5f\n', n(i), l(i), m(i), k(i), ...
plek, pgtk, peqk);
end
g01bl example results
n l m k plek pgtk peqk
10 2 5 1 0.77778 0.22222 0.55556
40 10 3 2 0.98785 0.01215 0.13664
155 35 122 22 0.01101 0.98899 0.00779
1000 444 500 220 0.42429 0.57571 0.04913
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015