g01 Chapter Contents
g01 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_prob_beta_dist (g01eec)

## 1  Purpose

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

## 2  Specification

 #include #include
 void nag_prob_beta_dist (double x, double a, double b, double tol, double *p, double *q, double *pdf, NagError *fail)

## 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 nag_incomplete_beta (s14ccc).

## 4  References

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

## 5  Arguments

1:    $\mathbf{x}$doubleInput
On entry: $\beta$, the value of the beta variate.
Constraint: $0.0\le {\mathbf{x}}\le 1.0$.
2:    $\mathbf{a}$doubleInput
On entry: $a$, the first parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{a}}\le {10}^{6}$.
3:    $\mathbf{b}$doubleInput
On entry: $b$, the second parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{b}}\le {10}^{6}$.
4:    $\mathbf{tol}$doubleInput
On entry: this argument is no longer referenced, but is included for backwards compatability.
5:    $\mathbf{p}$double *Output
On exit: the lower tail probability, $P\left(B\le \beta :a,b\right)$.
6:    $\mathbf{q}$double *Output
On exit: the upper tail probability, $P\left(B\ge \beta :a,b\right)$.
7:    $\mathbf{pdf}$double *Output
On exit: the probability density function, $f\left(B:a,b\right)$.
8:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.2.1.2 in the Essential Introduction for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 3.6.6 in the Essential Introduction for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 3.6.5 in the Essential Introduction for further information.
NE_REAL_ARG_GT
On entry, ${\mathbf{x}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{x}}\le 1.0$.
NE_REAL_ARG_LE
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$.
NE_REAL_ARG_LT
On entry, ${\mathbf{x}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{x}}\ge 0.0$.

## 7  Accuracy

The accuracy is limited by the error in the incomplete beta function. See Section 7 in nag_incomplete_beta (s14ccc) for further details.

Not applicable.

None.

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

### 10.1  Program Text

Program Text (g01eece.c)

### 10.2  Program Data

Program Data (g01eece.d)

### 10.3  Program Results

Program Results (g01eece.r)