Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_stat_prob_beta (g01ee)

Purpose

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

Syntax

[p, q, pdf, ifail] = g01ee(x, a, b)
[p, q, pdf, ifail] = nag_stat_prob_beta(x, a, b)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: tol dropped from interface
.

Description

The probability density function of the beta distribution with parameters a$a$ and b$b$ is:
 f(B : a,b) = (Γ(a + b))/(Γ(a)Γ(b))Ba − 1(1 − B)b − 1,  0 ≤ B ≤ 1;a,b > 0. $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(Bβ : a,b)$P\left(B\le \beta :a,b\right)$ is defined by
 β P(B ≤ β : a,b) = (Γ(a + b))/(Γ(a)Γ(b)) ∫ Ba − 1(1 − B)b − 1dB = Iβ(a,b),  0 ≤ β ≤ 1;a,b > 0. 0
$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 Ix(a,b)${I}_{x}\left(a,b\right)$, also known as the incomplete beta function is calculated using nag_specfun_beta_incomplete (s14cc).

References

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

Parameters

Compulsory Input Parameters

1:     x – double scalar
β$\beta$, the value of the beta variate.
Constraint: 0.0x1.0$0.0\le {\mathbf{x}}\le 1.0$.
2:     a – double scalar
a$a$, the first parameter of the required beta distribution.
Constraint: 0.0 < a106$0.0<{\mathbf{a}}\le {10}^{6}$.
3:     b – double scalar
b$b$, the second parameter of the required beta distribution.
Constraint: 0.0 < b106$0.0<{\mathbf{b}}\le {10}^{6}$.

None.

tol

Output Parameters

1:     p – double scalar
The lower tail probability, P(Bβ : a,b)$P\left(B\le \beta :a,b\right)$.
2:     q – double scalar
The upper tail probability, P(Bβ : a,b)$P\left(B\ge \beta :a,b\right)$.
3:     pdf – double scalar
The probability density function, f(B : a,b)$f\left(B:a,b\right)$.
4:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Note: nag_stat_prob_beta (g01ee) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

ifail = 1${\mathbf{ifail}}=1$
 On entry, x < 0.0${\mathbf{x}}<0.0$, or x > 1.0${\mathbf{x}}>1.0$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, a ≤ 0.0${\mathbf{a}}\le 0.0$, or a > 106${\mathbf{a}}>{10}^{6}$, or b ≤ 0.0${\mathbf{b}}\le 0.0$, or b > 106${\mathbf{b}}>{10}^{6}$.
W ifail = 4${\mathbf{ifail}}=4$
x is too far out into the tails for the probability to be evaluated exactly. The results returned are 0$0$ and 1$1$ as appropriate. These should be a good approximation to the required solution.

Accuracy

The accuracy is limited by the error in the incomplete beta function. See Section [Accuracy] in (s14cc) for further details.

None.

Example

```function nag_stat_prob_beta_example
x = 0.25;
a = 1;
b = 2;
[p, q, pdf, ifail] = nag_stat_prob_beta(x, a, b)
```
```

p =

0.4375

q =

0.5625

pdf =

1.5000

ifail =

0

```
```function g01ee_example
x = 0.25;
a = 1;
b = 2;
[p, q, pdf, ifail] = g01ee(x, a, b)
```
```

p =

0.4375

q =

0.5625

pdf =

1.5000

ifail =

0

```