NAG Library Routine Document

g01eef (prob_beta)

1
Purpose

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

2
Specification

Fortran Interface
Subroutine g01eef ( x, a, b, tol, p, q, pdf, ifail)
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: x, a, b, tol
Real (Kind=nag_wp), Intent (Out):: p, q, pdf
C Header Interface
#include <nagmk26.h>
void  g01eef_ (const double *x, const double *a, const double *b, const double *tol, double *p, double *q, double *pdf, Integer *ifail)

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,  0B1;a,b>0.  
The lower tail probability, PBβ:a,b 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 Ixa,b, also known as the incomplete beta function is calculated using s14ccf.

4
References

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

5
Arguments

1:     x – Real (Kind=nag_wp)Input
On entry: β, the value of the beta variate.
Constraint: 0.0x1.0.
2:     a – Real (Kind=nag_wp)Input
On entry: a, the first parameter of the required beta distribution.
Constraint: 0.0<a106.
3:     b – Real (Kind=nag_wp)Input
On entry: b, the second parameter of the required beta distribution.
Constraint: 0.0<b106.
4:     tol – Real (Kind=nag_wp)Input
On entry: this argument is no longer referenced, but is included for backwards compatability.
5:     p – Real (Kind=nag_wp)Output
On exit: the lower tail probability, PBβ:a,b.
6:     q – Real (Kind=nag_wp)Output
On exit: the upper tail probability, PBβ:a,b.
7:     pdf – Real (Kind=nag_wp)Output
On exit: the probability density function, fB:a,b.
8:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 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 ifail0 on exit, the recommended value is -1. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Note: g01eef may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
ifail=1
On entry, x=value.
Constraint: x1.0.
On entry, x=value.
Constraint: x0.0.
ifail=2
On entry, a=value and b=value.
Constraint: a>0.0.
On entry, a=value and b=value.
Constraint: b>0.0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

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

8
Parallelism and Performance

g01eef is not threaded in any implementation.

9
Further Comments

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 (g01eefe.f90)

10.2
Program Data

Program Data (g01eefe.d)

10.3
Program Results

Program Results (g01eefe.r)