G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG01EEF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G01EEF computes the upper and lower tail probabilities and the probability density function of the beta distribution with parameters $a$ and $b$.

## 2  Specification

 SUBROUTINE G01EEF ( X, A, B, TOL, P, Q, PDF, IFAIL)
 INTEGER IFAIL REAL (KIND=nag_wp) X, A, B, TOL, P, Q, PDF

## 3  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 S14CCF.

## 4  References

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

## 5  Parameters

1:     X – REAL (KIND=nag_wp)Input
On entry: $\beta$, the value of the beta variate.
Constraint: $0.0\le {\mathbf{X}}\le 1.0$.
2:     A – REAL (KIND=nag_wp)Input
On entry: $a$, the first parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{A}}\le {10}^{6}$.
3:     B – REAL (KIND=nag_wp)Input
On entry: $b$, the second parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{B}}\le {10}^{6}$.
4:     TOL – REAL (KIND=nag_wp)Input
On entry: this parameter is no longer referenced, but is included for backwards compatability.
5:     P – REAL (KIND=nag_wp)Output
On exit: the lower tail probability, $P\left(B\le \beta :a,b\right)$.
6:     Q – REAL (KIND=nag_wp)Output
On exit: the upper tail probability, $P\left(B\ge \beta :a,b\right)$.
7:     PDF – REAL (KIND=nag_wp)Output
On exit: the probability density function, $f\left(B:a,b\right)$.
8:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if ${\mathbf{IFAIL}}\ne {\mathbf{0}}$ on exit, the recommended value is $-1$. When the value $-\mathbf{1}\text{​ or ​}1$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: G01EEF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
${\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}$.
${\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.

## 7  Accuracy

The accuracy is limited by the error in the incomplete beta function. See Section 7 in S14CCF for further details.

None.

## 9  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.

### 9.1  Program Text

Program Text (g01eefe.f90)

### 9.2  Program Data

Program Data (g01eefe.d)

### 9.3  Program Results

Program Results (g01eefe.r)