# NAG CL Interfaceg01eec (prob_​beta)

Settings help

CL Name Style:

## 1Purpose

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

## 2Specification

 #include
 void g01eec (double x, double a, double b, double tol, double *p, double *q, double *pdf, NagError *fail)
The function may be called by the names: g01eec, nag_stat_prob_beta or nag_prob_beta_dist.

## 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 s14ccc.
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth

## 5Arguments

1: $\mathbf{x}$double Input
On entry: $\beta$, the value of the beta variate.
Constraint: $0.0\le {\mathbf{x}}\le 1.0$.
2: $\mathbf{a}$double Input
On entry: $a$, the first parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{a}}\le {10}^{6}$.
3: $\mathbf{b}$double Input
On entry: $b$, the second parameter of the required beta distribution.
Constraint: $0.0<{\mathbf{b}}\le {10}^{6}$.
4: $\mathbf{tol}$double Input
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 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
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 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface 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$.

## 7Accuracy

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

## 8Parallelism and Performance

g01eec 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 (g01eece.c)

### 10.2Program Data

Program Data (g01eece.d)

### 10.3Program Results

Program Results (g01eece.r)