hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_stat_prob_beta (g01ee)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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 and 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:
At Mark 23: tol was removed from the interface

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 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
β, the value of the beta variate.
Constraint: 0.0x1.0.
2:     a – double scalar
a, the first parameter of the required beta distribution.
Constraint: 0.0<a106.
3:     b – double scalar
b, the second parameter of the required beta distribution.
Constraint: 0.0<b106.

Optional Input Parameters

None.

Output Parameters

1:     p – double scalar
The lower tail probability, PBβ:a,b.
2:     q – double scalar
The upper tail probability, PBβ:a,b.
3:     pdf – double scalar
The probability density function, fB:a,b.
4:     ifail int64int32nag_int scalar
ifail=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
On entry,x<0.0,
orx>1.0.
   ifail=2
On entry,a0.0,
ora>106,
orb0.0,
orb>106.
W  ifail=4
x is too far out into the tails for the probability to be evaluated exactly. The results returned are 0 and 1 as appropriate. These should be a good approximation to the required solution.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

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

Further Comments

None.

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.
function g01ee_example


fprintf('g01ee example results\n\n');

% Lower and upper tail probabilities for Beta distribution
x = [0.25; 0.75; 0.50];
a = [1.00; 1.50; 2.00];
b = [2.00; 1.50; 1.00];

fprintf('    x       a       b       p       q       pdf\n');
for j = 1:numel(x)

  [p, q, pdf, ifail] = g01ee( ...
                              x(j), a(j), b(j));

 fprintf('%8.4f', x(j), a(j), b(j), p, q, pdf);
 fprintf('\n')
end


g01ee example results

    x       a       b       p       q       pdf
  0.2500  1.0000  2.0000  0.4375  0.5625  1.5000
  0.7500  1.5000  1.5000  0.8045  0.1955  1.1027
  0.5000  2.0000  1.0000  0.2500  0.7500  1.0000

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015