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 (g01ee)

## Purpose

nag_stat_prob_beta (g01ee) computes the upper and lower tail probabilities and the probability density function of the beta distribution with parameters $a$ and $b$.

## Syntax

[p, q, pdf, ifail] = g01ee(x, a, b)
[p, q, pdf, ifail] = nag_stat_prob_beta(x, a, b)
Note: the interface to this routine has changed since earlier releases of the toolbox:
 At Mark 23: tol was removed from the interface

## Description

The probability density function of the beta distribution with parameters $a$ and $b$ is:
 $fB:a,b=Γa+b ΓaΓb Ba-11-Bb-1, 0≤B≤1;a,b>0.$
The lower tail probability, $P\left(B\le \beta :a,b\right)$ is defined by
 $PB≤β:a,b=Γa+b ΓaΓb ∫0βBa-11-Bb-1dB=Iβa,b, 0≤β≤1;a,b>0.$
The function ${I}_{x}\left(a,b\right)$, also known as the incomplete beta function is calculated using nag_specfun_beta_incomplete (s14cc).

## References

Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{x}$ – double scalar
$\beta$, the value of the beta variate.
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}$.

None.

### Output Parameters

1:     $\mathrm{p}$ – double scalar
The lower tail probability, $P\left(B\le \beta :a,b\right)$.
2:     $\mathrm{q}$ – double scalar
The upper tail probability, $P\left(B\ge \beta :a,b\right)$.
3:     $\mathrm{pdf}$ – double scalar
The probability density function, $f\left(B:a,b\right)$.
4:     $\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 (g01ee) 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{x}}<0.0$, or ${\mathbf{x}}>1.0$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{a}}\le 0.0$, or ${\mathbf{a}}>{10}^{6}$, or ${\mathbf{b}}\le 0.0$, or ${\mathbf{b}}>{10}^{6}$.
W  ${\mathbf{ifail}}=4$
x is too far out into the tails for the probability to be evaluated exactly. The results returned are $0$ and $1$ as appropriate. These should be a good approximation to the required solution.
${\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

The accuracy is limited by the error in the incomplete beta function. See Accuracy in nag_specfun_beta_incomplete (s14cc) for further details.

None.

## Example

This example reads values from a number of beta distributions and computes the associated upper and lower tail probabilities and the corresponding value of the probability density function.
```function g01ee_example

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

% Lower and upper tail probabilities for Beta distribution
x = [0.25; 0.75; 0.50];
a = [1.00; 1.50; 2.00];
b = [2.00; 1.50; 1.00];

fprintf('    x       a       b       p       q       pdf\n');
for j = 1:numel(x)

[p, q, pdf, ifail] = g01ee( ...
x(j), a(j), b(j));

fprintf('%8.4f', x(j), a(j), b(j), p, q, pdf);
fprintf('\n')
end

```
```g01ee example results

x       a       b       p       q       pdf
0.2500  1.0000  2.0000  0.4375  0.5625  1.5000
0.7500  1.5000  1.5000  0.8045  0.1955  1.1027
0.5000  2.0000  1.0000  0.2500  0.7500  1.0000
```