Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_stat_prob_beta_noncentral (g01ge)

## Purpose

nag_stat_prob_beta_noncentral (g01ge) returns the probability associated with the lower tail of the noncentral beta distribution.

## Syntax

[result, ifail] = g01ge(x, a, b, rlamda, 'tol', tol, 'maxit', maxit)
[result, ifail] = nag_stat_prob_beta_noncentral(x, a, b, rlamda, 'tol', tol, 'maxit', maxit)
Note: the interface to this routine has changed since earlier releases of the toolbox:
 At Mark 23: tol was made optional (default 0)

## Description

The lower tail probability for the noncentral beta distribution with parameters $a$ and $b$ and noncentrality parameter $\lambda$, $P\left(B\le \beta :a,b\text{;}\lambda \right)$, is defined by
 $PB≤β:a,b;λ=∑j=0∞e-λ/2 λ/2 j! PB≤β:a,b;0,$ (1)
where
 $PB≤β : a,b;0=Γ a+b Γ aΓ b ∫0βBa- 11-Bb- 1dB,$
which is the central beta probability function or incomplete beta function.
Recurrence relationships given in Abramowitz and Stegun (1972) are used to compute the values of $P\left(B\le \beta :a,b\text{;}0\right)$ for each step of the summation (1).
The algorithm is discussed in Lenth (1987).

## References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Lenth R V (1987) Algorithm AS 226: Computing noncentral beta probabilities Appl. Statist. 36 241–244

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{x}$ – double scalar
$\beta$, the deviate from the beta distribution, for which the probability $P\left(B\le \beta :a,b\text{;}\lambda \right)$ is to be found.
Constraint: $0.0\le {\mathbf{x}}\le 1.0$.
2:     $\mathrm{a}$ – double scalar
$a$, the first parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{a}}\le {10}^{6}$.
3:     $\mathrm{b}$ – double scalar
$b$, the second parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{b}}\le {10}^{6}$.
4:     $\mathrm{rlamda}$ – double scalar
$\lambda$, the noncentrality parameter of the required beta distribution.
Constraint: $0.0\le {\mathbf{rlamda}}\le -2.0\mathrm{log}\left(U\right)$, where $U$ is the safe range parameter as defined by nag_machine_real_safe (x02am).

### Optional Input Parameters

1:     $\mathrm{tol}$ – double scalar
Default: $0.0$
The relative accuracy required by you in the results. If nag_stat_prob_beta_noncentral (g01ge) is entered with tol greater than or equal to $1.0$ or less than  (see nag_machine_precision (x02aj)), then the value of  is used instead.
See Accuracy for the relationship between tol and maxit.
2:     $\mathrm{maxit}$int64int32nag_int scalar
Default: $500$.
The maximum number of iterations that the algorithm should use.
See Accuracy for suggestions as to suitable values for maxit for different values of the arguments.
Constraint: ${\mathbf{maxit}}\ge 1$.

### Output Parameters

1:     $\mathrm{result}$ – double scalar
The result of the function.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Note: nag_stat_prob_beta_noncentral (g01ge) 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.

${\mathbf{ifail}}=1$
 On entry, ${\mathbf{a}}\le 0.0$, or ${\mathbf{a}}>{10}^{6}$, or ${\mathbf{b}}\le 0.0$, or ${\mathbf{b}}>{10}^{6}$, or ${\mathbf{rlamda}}<0.0$, or ${\mathbf{rlamda}}>-2.0\mathrm{log}\left(U\right)$, where $U=\text{}$ safe range argument as defined by nag_machine_real_safe (x02am), or ${\mathbf{x}}<0.0$, or ${\mathbf{x}}>1.0$, or ${\mathbf{maxit}}<1$.
If on exit ${\mathbf{ifail}}={\mathbf{1}}$ then nag_stat_prob_beta_noncentral (g01ge) returns zero.
W  ${\mathbf{ifail}}=2$
The solution has failed to converge in maxit iterations. You should try a larger value of maxit or tol. The returned value will be an approximation to the correct value.
W  ${\mathbf{ifail}}=3$
The probability is too close to $0.0$ or $1.0$ for the algorithm to be able to calculate the required probability. nag_stat_prob_beta_noncentral (g01ge) will return $0.0$ or $1.0$ as appropriate, this should be a reasonable approximation.
W  ${\mathbf{ifail}}=4$
The required accuracy was not achieved when calculating the initial value of $P\left(B\le \beta :a,b\text{;}\lambda \right)$. You should try a larger value of tol. The returned value will be an approximation to the correct value.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

Convergence is theoretically guaranteed whenever $P\left(Y>{\mathbf{maxit}}\right)\le {\mathbf{tol}}$ where $Y$ has a Poisson distribution with mean $\lambda /2$. Excessive round-off errors are possible when the number of iterations used is high and tol is close to machine precision. See Lenth (1987) for further comments on the error bound.

The central beta probabilities can be obtained by setting ${\mathbf{rlamda}}=0.0$.

## Example

This example reads values for several beta distributions and calculates and prints the lower tail probabilities until the end of data is reached.
```function g01ge_example

fprintf('g01ge example results\n\n');

x      = [ 0.25   0.75   0.5];
a      = [ 1      1.5    2  ];
b      = [ 2      1.5    1  ];
rlamda = [ 1      0.5    0  ];
p      = x;

fprintf('     x       a       b     rlamda    p\n');
for j = 1:numel(x)
[p(j), ifail] = g01ge( ...
x(j), a(j), b(j), rlamda(j));
end

fprintf('%8.3f%8.3f%8.3f%8.3f%8.4f\n', [x; a; b; rlamda; p]);

```
```g01ge example results

x       a       b     rlamda    p
0.250   1.000   2.000   1.000  0.3168
0.750   1.500   1.500   0.500  0.7705
0.500   2.000   1.000   0.000  0.2500
```