|
NAG[g05exc] NAG[nag_ref_vec_discrete_pdf_cdf] - Set up reference vector from supplied cumulative distribution function or probability distribution function
|
|
Calling Sequence
g05exc(p, sizep, distf, r, 'np'=np, 'fail'=fail)
nag_ref_vec_discrete_pdf_cdf(. . .)
Parameters
|
p - Vector(1..np, datatype=float[8]);
|
|
|
On entry: the PDF or CDF of the distribution.
|
|
|
sizep - integer;
|
|
|
On entry: the value of the variate, assumed to be a whole number, to which the probability in corresponds.
|
|
|
distf - String;
|
|
|
On entry: indicates the type of information contained in p.
|
|
p contains a cumulative distribution function (CDF).
|
|
p contains a probability density function (PDF).
|
|
Constraint: "Nag_PDF" or "Nag_CDF". .
|
|
|
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.
|
|
|
'np'=np - integer; (optional)
|
|
|
Default value: the dimension of the array p.
|
|
On entry: the first dimension of the array p as declared in the function from which nag_ref_vec_discrete_pdf_cdf (g05exc) is called. np is used in the calculation of the length of the reference vector.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_ref_vec_discrete_pdf_cdf (g05exc) sets up the reference vector R for a discrete distribution with probability density function (PDF) or cumulative distribution function (CDF) p.
|
|
Description
|
|
nag_ref_vec_discrete_pdf_cdf (g05exc) sets up a reference vector for use in g05eyc (nag_return_discrete) according to information supplied by the user in p. This may either be the PDF or CDF of the distribution.
|
|
Error Indicators and Warnings
|
|
"NE_ALLOC_FAIL"
Dynamic memory allocation failed.
"NE_ALL_PROB_ZERO"
All the probabilities in array p are zero.
"NE_BAD_PARAM"
On entry, argument distf had an illegal value.
"NE_INT_ARG_LT"
On entry, np must not be less than 1: .
"NE_NEG_PROB"
At least one of the probabilities in array p is negative, .
"NE_NOT_INCREASING"
and the sequence p is not increasing: , .
"NE_PROB_NOT_ONE"
The total probability is not 1, may be due to rounding errors, total probability .
|
|
|
Examples
|
|
>
|
np := 10:
sizep := 0:
distf := "Nag_CDF":
p := Vector([0, 0.1, 0.2, 0.4, 0.5, 0.6, 0.8, 0.9, 1, 1], datatype=float[8]):
NAG:-g05cbc(0):
NAG:-g05exc(p, sizep, distf, r, 'np' = np):
x := Vector(5):
for i from 1 to 5 do
x[i] := NAG:-g05eyc(r):
end do:
|
|
|
Download Help Document
Was this information helpful?