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:
Mark 23: tol now optional (default 0)
.

## Description

The lower tail probability for the noncentral beta distribution with parameters a$a$ and b$b$ and noncentrality parameter λ$\lambda$, P(Bβ : a,b;λ)$P\left(B\le \beta :a,b\text{;}\lambda \right)$, is defined by
 ∞ P(B ≤ β : a,b;λ) = ∑ e − λ / 2((λ / 2))/(j ! )P(B ≤ β : a,b;0), j = 0
$P(B≤β:a,b;λ)=∑j=0∞e-λ/2 (λ/2) j! P(B≤β:a,b;0),$
(1)
where
 β P(B ≤ β : a,b;0) = (Γ (a + b))/(Γ (a)Γ (b)) ∫ Ba − 1(1 − B)b − 1dB, 0
$P(B≤β : a,b;0)=Γ (a+b) Γ (a)Γ (b) ∫0βBa- 1(1-B)b- 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(Bβ : a,b;0)$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:     x – double scalar
β$\beta$, the deviate from the beta distribution, for which the probability P(Bβ : a,b;λ)$P\left(B\le \beta :a,b\text{;}\lambda \right)$ is to be found.
Constraint: 0.0x1.0$0.0\le {\mathbf{x}}\le 1.0$.
2:     a – double scalar
a$a$, the first parameter of the required beta distribution.
Constraint: 0.0 < a106$0.0<{\mathbf{a}}\le {10}^{6}$.
3:     b – double scalar
b$b$, the second parameter of the required beta distribution.
Constraint: 0.0 < b106$0.0<{\mathbf{b}}\le {10}^{6}$.
4:     rlamda – double scalar
λ$\lambda$, the noncentrality parameter of the required beta distribution.
Constraint: 0.0rlamda2.0log(U)$0.0\le {\mathbf{rlamda}}\le -2.0\mathrm{log}\left(U\right)$, where U$U$ is the safe range parameter as defined by nag_machine_real_safe (x02am).

### Optional Input Parameters

1:     tol – double scalar
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$1.0$ or less than 10 × machine precision (see nag_machine_precision (x02aj)), then the value of 10 × machine precision is used instead.
See Section [Accuracy] for the relationship between tol and maxit.
Default: 0.0$0.0$
2:     maxit – int64int32nag_int scalar
The maximum number of iterations that the algorithm should use.
See Section [Accuracy] for suggestions as to suitable values for maxit for different values of the parameters.
Default: 500$500$.
Constraint: maxit1${\mathbf{maxit}}\ge 1$.

None.

### Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail – int64int32nag_int scalar
${\mathrm{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.

ifail = 1${\mathbf{ifail}}=1$
 On entry, a ≤ 0.0${\mathbf{a}}\le 0.0$, or a > 106${\mathbf{a}}>{10}^{6}$, or b ≤ 0.0${\mathbf{b}}\le 0.0$, or b > 106${\mathbf{b}}>{10}^{6}$, or rlamda < 0.0${\mathbf{rlamda}}<0.0$, or rlamda > − 2.0log(U)${\mathbf{rlamda}}>-2.0\mathrm{log}\left(U\right)$, where U = $U=\text{}$ safe range parameter as defined by nag_machine_real_safe (x02am), or x < 0.0${\mathbf{x}}<0.0$, or x > 1.0${\mathbf{x}}>1.0$, or maxit < 1${\mathbf{maxit}}<1$.
If on exit ${\mathbf{ifail}}={\mathbf{1}}$ then nag_stat_prob_beta_noncentral (g01ge) returns zero.
W ifail = 2${\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 ifail = 3${\mathbf{ifail}}=3$
The probability is too close to 0.0$0.0$ or 1.0$1.0$ for the algorithm to be able to calculate the required probability. nag_stat_prob_beta_noncentral (g01ge) will return 0.0$0.0$ or 1.0$1.0$ as appropriate, this should be a reasonable approximation.
W ifail = 4${\mathbf{ifail}}=4$
The required accuracy was not achieved when calculating the initial value of P(Bβ : a,b;λ)$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.

## Accuracy

Convergence is theoretically guaranteed whenever P(Y > maxit)tol$P\left(Y>{\mathbf{maxit}}\right)\le {\mathbf{tol}}$ where Y$Y$ has a Poisson distribution with mean λ / 2$\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 rlamda = 0.0${\mathbf{rlamda}}=0.0$.

## Example

```function nag_stat_prob_beta_noncentral_example
x = 0.25;
a = 1;
b = 2;
rlamda = 1;
[result, ifail] = nag_stat_prob_beta_noncentral(x, a, b, rlamda)
```
```

result =

0.3168

ifail =

0

```
```function g01ge_example
x = 0.25;
a = 1;
b = 2;
rlamda = 1;
[result, ifail] = g01ge(x, a, b, rlamda)
```
```

result =

0.3168

ifail =

0

```