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_inv_cdf_students_t (g01fb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_stat_inv_cdf_students_t (g01fb) returns the deviate associated with the given tail probability of Student's t-distribution with real degrees of freedom.

Syntax

[result, ifail] = g01fb(p, df, 'tail', tail)
[result, ifail] = nag_stat_inv_cdf_students_t(p, df, 'tail', tail)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: tail was made optional (default 'L')

Description

The deviate, tp associated with the lower tail probability, p, of the Student's t-distribution with ν degrees of freedom is defined as the solution to
PT<tp:ν=p=Γν+1/2 νπΓν/2 -tp 1+T2ν -ν+1/2dT,  ν1; ​-<tp<.  
For ν=1​ or ​2 the integral equation is easily solved for tp.
For other values of ν<3 a transformation to the beta distribution is used and the result obtained from nag_stat_inv_cdf_beta (g01fe).
For ν3 an inverse asymptotic expansion of Cornish–Fisher type is used. The algorithm is described by Hill (1970).

References

Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Hill G W (1970) Student's t-distribution Comm. ACM 13(10) 617–619

Parameters

Compulsory Input Parameters

1:     p – double scalar
p, the probability from the required Student's t-distribution as defined by tail.
Constraint: 0.0<p<1.0.
2:     df – double scalar
ν, the degrees of freedom of the Student's t-distribution.
Constraint: df1.0.

Optional Input Parameters

1:     tail – string (length ≥ 1)
Default: 'L'
Indicates which tail the supplied probability represents.
tail='U'
The upper tail probability, i.e., PTtp:ν.
tail='L'
The lower tail probability, i.e., PTtp:ν.
tail='S'
The two tail (significance level) probability, i.e., PTtp:ν+PT-tp:ν.
tail='C'
The two tail (confidence interval) probability, i.e., PTtp:ν-PT-tp:ν.
Constraint: tail='U', 'L', 'S' or 'C'.

Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Note: nag_stat_inv_cdf_students_t (g01fb) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
If ifail=1, 2 or 3 on exit, then nag_stat_inv_cdf_students_t (g01fb) returns zero.

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,tail'U', 'S', 'C' or 'L'.
   ifail=2
On entry,p0.0,
orp1.0.
   ifail=3
On entry,df<1.0.
W  ifail=5
Convergence in the calculation of the inverse beta value was not achieved. However, the result should be a reasonable approximation to the correct value.
   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 results should be accurate to five significant digits, for most argument values. The error behaviour for various argument values is discussed in Hill (1970).

Further Comments

The value tp may be calculated by using the transformation described in Description and using nag_stat_inv_cdf_beta (g01fe). This function allows you to set the required accuracy.

Example

This example reads the probability, the tail that probability represents and the degrees of freedom for a number of Student's t-distributions and computes the corresponding deviates.
function g01fb_example


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

p    = [ 0.01;          0.01;        0.99];
df   = [20;             7.5;        45.00];
tail = {'Significance'; 'Lower'; 'Confidence' };

fprintf('      p      df    tail      x\n');
for j = 1:numel(p);

  [x, ifail] = g01fb( ...
                      p(j) , df(j), 'tail', tail{j});

  fprintf('%9.3f%8.3f%4s%12.3f\n', p(j), df(j), tail{j}(1), x);
end


g01fb example results

      p      df    tail      x
    0.010  20.000   S       2.845
    0.010   7.500   L      -2.943
    0.990  45.000   C       2.690

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