# NAG FL Interfaceg01eef (prob_​beta)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 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:
 $f(B:a,b)=Γ(a+b) Γ(a)Γ(b) Ba-1(1-B)b-1, 0≤B≤1;a,b>0.$
The lower tail probability, $P\left(B\le \beta :a,b\right)$ is defined by
 $P(B≤β:a,b)=Γ(a+b) Γ(a)Γ(b) ∫0βBa-1(1-B)b-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.
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$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $-1$ is recommended since useful values can be provided in some output arguments even when ${\mathbf{ifail}}\ne {\mathbf{0}}$ on exit. When the value $-\mathbf{1}$ or $\mathbf{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).

## 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)