|
NAG[g05edc] NAG[nag_ref_vec_binomial] - Set up reference vector for generating pseudo-random integers, binomial distribution
|
|
Calling Sequence
g05edc(n, p, r, 'fail'=fail)
nag_ref_vec_binomial(. . .)
Parameters
|
n - integer;
|
|
|
On entry: the number of trials, , of the distribution.
|
|
Constraint: . .
|
|
|
p - float;
|
|
|
On entry: the probability of success, , of the distribution.
|
|
Constraint: . .
|
|
|
r - assignable;
|
|
|
Note: On exit the variable r will have a value of type REF(float).
|
|
On exit: reference vector for which memory will be allocated internally. If no memory is allocated to r (e.g., when an input error is detected) then r will be NULL on return, otherwise the user should use the NAG macro NAG_FREE to free the storage allocated by r when it is no longer of use.
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_ref_vec_binomial (g05edc) sets up the reference vector r for a binomial distribution of the number of successes in trials, each with probability of success .
|
|
Description
|
|
nag_ref_vec_binomial (g05edc) sets up a reference vector for use in g05eyc (nag_return_discrete). Together these functions produce random numbers from the binomial distribution defined by:
The reference array is found by a recurrence relation if ; otherwise Stirling's approximation is used.
|
|
Error Indicators and Warnings
|
|
"NE_ALLOC_FAIL"
Dynamic memory allocation failed.
"NE_INT_ARG_LT"
On entry, n must not be less than 0: .
"NE_REAL_ARG_GT"
On entry, p must not be greater than 1.0: .
"NE_REAL_ARG_LT"
On entry, p must not be less than 0.0: .
|
|
|
Examples
|
|
>
|
n := 100:
p := 0.5:
NAG:-g05cbc(0):
NAG:-g05edc(n, p, r):
x := Vector(5):
for i from 1 to 5 do
x[i] := NAG:-g05eyc(r):
end do:
|
|
|
Download Help Document
Was this information helpful?