PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_stat_inv_cdf_beta_vector (g01te)
Purpose
nag_stat_inv_cdf_beta_vector (g01te) returns a number of deviates associated with given probabilities of the beta distribution.
Syntax
[
beta,
ivalid,
ifail] = g01te(
tail,
p,
a,
b, 'ltail',
ltail, 'lp',
lp, 'la',
la, 'lb',
lb, 'tol',
tol)
[
beta,
ivalid,
ifail] = nag_stat_inv_cdf_beta_vector(
tail,
p,
a,
b, 'ltail',
ltail, 'lp',
lp, 'la',
la, 'lb',
lb, 'tol',
tol)
Description
The deviate,
, associated with the lower tail probability,
, of the beta distribution with parameters
and
is defined as the solution to
The algorithm is a modified version of the Newton–Raphson method, following closely that of
Cran et al. (1977).
An initial approximation,
, to
is found (see
Cran et al. (1977)), and the Newton–Raphson iteration
where
is used, with modifications to ensure that
remains in the range
.
The input arrays to this function are designed to allow maximum flexibility in the supply of vector arguments by re-using elements of any arrays that are shorter than the total number of evaluations required. See
Vectorized Routines in the G01 Chapter Introduction for further information.
References
Cran G W, Martin K J and Thomas G E (1977) Algorithm AS 109. Inverse of the incomplete beta function ratio Appl. Statist. 26 111–114
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Parameters
Compulsory Input Parameters
- 1:
– cell array of strings
-
Indicates which tail the supplied probabilities represent. For
, for
:
- The lower tail probability, i.e., .
- The upper tail probability, i.e., .
Constraint:
or , for .
- 2:
– double array
-
, the probability of the required beta distribution as defined by
tail with
,
.
Constraint:
, for .
- 3:
– double array
-
, the first parameter of the required beta distribution with , .
Constraint:
, for .
- 4:
– double array
-
, the second parameter of the required beta distribution with , .
Constraint:
, for .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
tail.
The length of the array
tail.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the array
p.
The length of the array
p.
Constraint:
.
- 3:
– int64int32nag_int scalar
-
Default:
the dimension of the array
a.
The length of the array
a.
Constraint:
.
- 4:
– int64int32nag_int scalar
-
Default:
the dimension of the array
b.
The length of the array
b.
Constraint:
.
- 5:
– double scalar
Default:
The relative accuracy required by you in the results. If
nag_stat_inv_cdf_beta_vector (g01te) is entered with
tol greater than or equal to
or less than
(see
nag_machine_precision (x02aj)), then the value of
is used instead.
Output Parameters
- 1:
– double array
-
The dimension of the array
beta will be
, the deviates for the beta distribution.
- 2:
– int64int32nag_int array
-
The dimension of the array
ivalid will be
indicates any errors with the input arguments, with
- No error.
On entry, | invalid value supplied in tail when calculating . |
On entry, | , |
or | . |
On entry, | , |
or | , |
or | , |
or | . |
- The solution has not converged but the result should be a reasonable approximation to the solution.
- Requested accuracy not achieved when calculating the beta probability. The result should be a reasonable approximation to the correct solution.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Note: nag_stat_inv_cdf_beta_vector (g01te) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
- W
-
On entry, at least one value of
tail,
p,
a, or
b was invalid, or the solution failed to converge.
Check
ivalid for more information.
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
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
The required precision, given by
tol, should be achieved in most circumstances.
Further Comments
The typical timing will be several times that of
nag_stat_prob_beta_vector (g01se) and will be very dependent on the input argument values. See
nag_stat_prob_beta_vector (g01se) for further comments on timings.
Example
This example reads lower tail probabilities for several beta distributions and calculates and prints the corresponding deviates.
Open in the MATLAB editor:
g01te_example
function g01te_example
fprintf('g01te example results\n\n');
tail = {'L'};
p = [0.5; 0.99; 0.25];
a = [1.0; 1.5; 20.0];
b = [2.0; 1.5; 10.0];
[x, ivalid, ifail] = g01te( ...
tail, p, a, b);
fprintf(' tail probability a b deviate ivalid\n');
ltail = numel(tail);
lp = numel(p);
la = numel(a);
lb = numel(b);
len = max ([ltail, lp, la, lb]);
for i=0:len-1
fprintf('%5s%9.4f%10.3f%10.3f%10.4f%8d\n', tail{mod(i, ltail)+1}, ...
p(mod(i,lp)+1), a(mod(i,la)+1), b(mod(i,lb)+1), x(i+1), ivalid(i+1));
end
g01te example results
tail probability a b deviate ivalid
L 0.5000 1.000 2.000 0.2929 0
L 0.9900 1.500 1.500 0.9672 0
L 0.2500 20.000 10.000 0.6105 0
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015