PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_stat_prob_binomial (g01bj)
Purpose
nag_stat_prob_binomial (g01bj) returns the lower tail, upper tail and point probabilities associated with a binomial distribution.
Syntax
Description
Let
denote a random variable having a binomial distribution with parameters
and
(
and
). Then
The mean of the distribution is
and the variance is
.
nag_stat_prob_binomial (g01bj) 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 binomial distribution.
Constraint:
.
- 2:
– double scalar
-
The parameter of the binomial distribution.
Constraint:
.
- 3:
– 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, | n is too large to be represented exactly as a double number. |
-
-
On entry, | the variance () exceeds . |
-
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_binomial (g01bj) depends on the variance () and on . For given variance, the time is greatest when (), 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:
g01bj_example
function g01bj_example
fprintf('g01bj example results\n\n');
n = int64([4 19 100 2000]);
k = int64([2 13 67 700]);
p = [0.5 0.44 0.75 0.33];
fprintf(' n p k plek pgtk peqk\n');
for i=1:4
[plek, pgtk, peqk, ifail] = ...
g01bj(n(i), p(i), k(i));
fprintf('%5d%7.3f%5d%10.5f%10.5f%10.5f\n', n(i), p(i), k(i), ...
plek, pgtk, peqk);
end
g01bj example results
n p k plek pgtk peqk
4 0.500 2 0.68750 0.31250 0.37500
19 0.440 13 0.99138 0.00862 0.01939
100 0.750 67 0.04460 0.95540 0.01700
2000 0.330 700 0.97251 0.02749 0.00312
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015