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_vector (g01se)

Purpose

nag_stat_prob_beta_vector (g01se) computes a number of lower or upper tail probabilities for the beta distribution.

Syntax

[p, ivalid, ifail] = g01se(tail, beta, a, b, 'ltail', ltail, 'lbeta', lbeta, 'la', la, 'lb', lb)
[p, ivalid, ifail] = nag_stat_prob_beta_vector(tail, beta, a, b, 'ltail', ltail, 'lbeta', lbeta, 'la', la, 'lb', lb)

Description

The lower tail probability, P( Bi βi : ai,bi) P( Bi βi :ai,bi)  is defined by
βi
P( Bi βi : ai,bi) = ( Γ (ai + bi) )/( Γ (ai) Γ (bi) )Biai1(1Bi)bi1dBi = Iβi(ai,bi),  0βi1; ai,bi > 0.
0
P( Bi βi :ai,bi) = Γ ( ai + bi ) Γ (ai) Γ (bi) 0 βi Bi ai-1 (1-Bi) bi-1 dBi = Iβi (ai,bi) ,   0 βi 1 ;  ai , bi > 0 .
The function Iβi(ai,bi)Iβi(ai,bi), also known as the incomplete beta function is calculated using nag_specfun_beta_incomplete (s14cc).
The input arrays to this function are designed to allow maximum flexibility in the supply of vector parameters by re-using elements of any arrays that are shorter than the total number of evaluations required. See Section [Vectorized s] in the G01 Chapter Introduction for further information.

References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Majumder K L and Bhattacharjee G P (1973) Algorithm AS 63. The incomplete beta integral Appl. Statist. 22 409–411

Parameters

Compulsory Input Parameters

1:     tail(ltail) – cell array of strings
ltail, the dimension of the array, must satisfy the constraint ltail > 0ltail>0.
Indicates whether a lower or upper tail probabilities are required. For j = ((i1)  mod  ltail) + 1 j= ( (i-1) mod ltail ) +1 , for i = 1,2,,max (ltail,lbeta,la,lb)i=1,2,,max(ltail,lbeta,la,lb):
tail(j) = 'L'tailj='L'
The lower tail probability is returned, i.e., pi = P( Bi βi : ai,bi) pi = P( Bi βi :ai,bi) .
tail(j) = 'U'tailj='U'
The upper tail probability is returned, i.e., pi = P( Bi βi : ai,bi) pi = P( Bi βi :ai,bi) .
Constraint: tail(j) = 'L'tailj='L' or 'U''U', for j = 1,2,,ltailj=1,2,,ltail.
2:     beta(lbeta) – double array
lbeta, the dimension of the array, must satisfy the constraint lbeta > 0lbeta>0.
βiβi, the value of the beta variate with βi = beta(j)βi=betaj, j = ((i1)  mod  lbeta) + 1j=((i-1) mod lbeta)+1.
Constraint: 0.0beta(j)1.00.0betaj1.0, for j = 1,2,,lbetaj=1,2,,lbeta.
3:     a(la) – double array
la, the dimension of the array, must satisfy the constraint la > 0la>0.
aiai, the first parameter of the required beta distribution with ai = a(j)ai=aj, j = ((i1)  mod  la) + 1j=((i-1) mod la)+1.
Constraint: a(j) > 0.0aj>0.0, for j = 1,2,,laj=1,2,,la.
4:     b(lb) – double array
lb, the dimension of the array, must satisfy the constraint lb > 0lb>0.
bibi, the second parameter of the required beta distribution with bi = b(j)bi=bj, j = ((i1)  mod  lb) + 1j=((i-1) mod lb)+1.
Constraint: b(j) > 0.0bj>0.0, for j = 1,2,,lbj=1,2,,lb.

Optional Input Parameters

1:     ltail – int64int32nag_int scalar
Default: The dimension of the array tail.
The length of the array tail.
Constraint: ltail > 0ltail>0.
2:     lbeta – int64int32nag_int scalar
Default: The dimension of the array beta.
The length of the array beta.
Constraint: lbeta > 0lbeta>0.
3:     la – int64int32nag_int scalar
Default: The dimension of the array a.
The length of the array a.
Constraint: la > 0la>0.
4:     lb – int64int32nag_int scalar
Default: The dimension of the array b.
The length of the array b.
Constraint: lb > 0lb>0.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     p( : :) – double array
Note: the dimension of the array p must be at least max (ltail,lbeta,la,lb)max(ltail,lbeta,la,lb).
pipi, the probabilities for the beta distribution.
2:     ivalid( : :) – int64int32nag_int array
Note: the dimension of the array ivalid must be at least max (ltail,lbeta,la,lb)max(ltail,lbeta,la,lb).
ivalid(i)ivalidi indicates any errors with the input arguments, with
ivalid(i) = 0ivalidi=0
No error.
ivalid(i) = 1ivalidi=1
On entry,invalid value supplied in tail when calculating pipi.
ivalid(i) = 2ivalidi=2
On entry,βi < 0.0βi<0.0,
orβi > 1.0βi>1.0.
ivalid(i) = 3ivalidi=3
On entry,ai0.0ai0.0,
orbi0.0bi0.0,
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Note: nag_stat_prob_beta_vector (g01se) 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.

W ifail = 1ifail=1
On entry, at least one value of beta, a, b or tail was invalid.
Check ivalid for more information.
  ifail = 2ifail=2
Constraint: ltail > 0ltail>0.
  ifail = 3ifail=3
Constraint: lbeta > 0lbeta>0.
  ifail = 4ifail=4
Constraint: la > 0la>0.
  ifail = 5ifail=5
Constraint: lb > 0lb>0.
  ifail = 999ifail=-999
Dynamic memory allocation failed.

Accuracy

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

Further Comments

None.

Example

function nag_stat_prob_beta_vector_example
tail = {'L'; 'L'; 'L'};
x = [0.25; 0.75; 0.5];
a = [1.0; 1.5; 2.0];
b = [2.0; 1.5; 1.0];
% calculate probability
[p, ivalid, ifail] = nag_stat_prob_beta_vector(tail, x, a, b);

fprintf('\n   X       A       B       P\n');
lx = numel(x);
la = numel(a);
lb = numel(b);
ltail = numel(tail);
len = max ([lx, la, lb, ltail]);
for i=0:len-1
 fprintf('%6.4f%8.4f%8.4f%8.4f  %5d\n', x(mod(i,lx)+1), a(mod(i,la)+1), ...
         b(mod(i,lb)+1), p(i+1), ivalid(i+1));
end
 

   X       A       B       P
0.2500  1.0000  2.0000  0.4375      0
0.7500  1.5000  1.5000  0.8045      0
0.5000  2.0000  1.0000  0.2500      0

function g01se_example
tail = {'L'; 'L'; 'L'};
x = [0.25; 0.75; 0.5];
a = [1.0; 1.5; 2.0];
b = [2.0; 1.5; 1.0];
% calculate probability
[p, ivalid, ifail] = g01se(tail, x, a, b);

fprintf('\n   X       A       B       P\n');
lx = numel(x);
la = numel(a);
lb = numel(b);
ltail = numel(tail);
len = max ([lx, la, lb, ltail]);
for i=0:len-1
 fprintf('%6.4f%8.4f%8.4f%8.4f  %5d\n', x(mod(i,lx)+1), a(mod(i,la)+1), ...
         b(mod(i,lb)+1), p(i+1), ivalid(i+1));
end
 

   X       A       B       P
0.2500  1.0000  2.0000  0.4375      0
0.7500  1.5000  1.5000  0.8045      0
0.5000  2.0000  1.0000  0.2500      0


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–2013