# NAG FL Interfaceg01eef (prob_​beta)

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine g01eef ( x, a, b, tol, p, q, pdf,
 Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: x, a, b, tol Real (Kind=nag_wp), Intent (Out) :: p, q, pdf
#include <nag.h>
 void g01eef_ (const double *x, const double *a, const double *b, const double *tol, double *p, double *q, double *pdf, Integer *ifail)
The routine may be called by the names g01eef or nagf_stat_prob_beta.

## 3Description

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.

## 4References

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

## 5Arguments

1: $\mathbf{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: $\mathbf{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: $\mathbf{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: $\mathbf{tol}$Real (Kind=nag_wp) Input
On entry: this argument is no longer referenced, but is included for backwards compatability.
5: $\mathbf{p}$Real (Kind=nag_wp) Output
On exit: the lower tail probability, $P\left(B\le \beta :a,b\right)$.
6: $\mathbf{q}$Real (Kind=nag_wp) Output
On exit: the upper tail probability, $P\left(B\ge \beta :a,b\right)$.
7: $\mathbf{pdf}$Real (Kind=nag_wp) Output
On exit: the probability density function, $f\left(B:a,b\right)$.
8: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, . If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value 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 arguments may be useful even if ${\mathbf{ifail}}\ne {\mathbf{0}}$ on exit, the recommended value is $-1$. When the value 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
Note: in some cases g01eef may return useful information.
${\mathbf{ifail}}=1$
On entry, ${\mathbf{x}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{x}}\le 1.0$.
On entry, ${\mathbf{x}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{x}}\ge 0.0$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{a}}=〈\mathit{\text{value}}〉$ and ${\mathbf{b}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{a}}>0.0$.
On entry, ${\mathbf{a}}=〈\mathit{\text{value}}〉$ and ${\mathbf{b}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{b}}>0.0$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

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

## 8Parallelism and Performance

g01eef is not threaded in any implementation.

None.

## 10Example

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.

### 10.1Program Text

Program Text (g01eefe.f90)

### 10.2Program Data

Program Data (g01eefe.d)

### 10.3Program Results

Program Results (g01eefe.r)