# NAG Library Routine Document

## 1Purpose

g01fbf returns the deviate associated with the given tail probability of Student's $t$-distribution with real degrees of freedom, via the routine name.

## 2Specification

Fortran Interface
 Function g01fbf ( tail, p, df,
 Real (Kind=nag_wp) :: g01fbf Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: p, df Character (1), Intent (In) :: tail
#include nagmk26.h
 double g01fbf_ (const char *tail, const double *p, const double *df, Integer *ifail, const Charlen length_tail)

## 3Description

The deviate, ${t}_{p}$ associated with the lower tail probability, $p$, of the Student's $t$-distribution with $\nu$ degrees of freedom is defined as the solution to
 $PT
For $\nu =1\text{​ or ​}2$ the integral equation is easily solved for ${t}_{p}$.
For other values of $\nu <3$ a transformation to the beta distribution is used and the result obtained from g01fef.
For $\nu \ge 3$ an inverse asymptotic expansion of Cornish–Fisher type is used. The algorithm is described by Hill (1970).

## 4References

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

## 5Arguments

1:     $\mathbf{tail}$ – Character(1)Input
On entry: indicates which tail the supplied probability represents.
${\mathbf{tail}}=\text{'U'}$
The upper tail probability, i.e., $P\left(T\ge {t}_{p}:\nu \right)$.
${\mathbf{tail}}=\text{'L'}$
The lower tail probability, i.e., $P\left(T\le {t}_{p}:\nu \right)$.
${\mathbf{tail}}=\text{'S'}$
The two tail (significance level) probability, i.e., $P\left(T\ge \left|{t}_{p}\right|:\nu \right)+P\left(T\le -\left|{t}_{p}\right|:\nu \right)$.
${\mathbf{tail}}=\text{'C'}$
The two tail (confidence interval) probability, i.e., $P\left(T\le \left|{t}_{p}\right|:\nu \right)-P\left(T\le -\left|{t}_{p}\right|:\nu \right)$.
Constraint: ${\mathbf{tail}}=\text{'U'}$, $\text{'L'}$, $\text{'S'}$ or $\text{'C'}$.
2:     $\mathbf{p}$ – Real (Kind=nag_wp)Input
On entry: $p$, the probability from the required Student's $t$-distribution as defined by tail.
Constraint: $0.0<{\mathbf{p}}<1.0$.
3:     $\mathbf{df}$ – Real (Kind=nag_wp)Input
On entry: $\nu$, the degrees of freedom of the Student's $t$-distribution.
Constraint: ${\mathbf{df}}\ge 1.0$.
4:     $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ 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\text{​ 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 ${\mathbf{ifail}}\ne {\mathbf{0}}$ on exit, the recommended value is $-1$. When the value $-\mathbf{1}\text{​ or ​}1$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Note: g01fbf may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
If ${\mathbf{ifail}}={\mathbf{1}}$, ${\mathbf{2}}$ or ${\mathbf{3}}$ on exit, then g01fbf returns zero.
${\mathbf{ifail}}=1$
On entry, ${\mathbf{tail}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{tail}}=\text{'L'}$, $\text{'U'}$, $\text{'S'}$ or $\text{'C'}$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{p}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{p}}<1.0$.
On entry, ${\mathbf{p}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{p}}>0.0$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{df}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{df}}\ge 1.0$.
${\mathbf{ifail}}=5$
The solution has failed to converge. However, the result should be a reasonable approximation.
${\mathbf{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.
${\mathbf{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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

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).

## 8Parallelism and Performance

g01fbf is not threaded in any implementation.

The value ${t}_{p}$ may be calculated by using the transformation described in Section 3 and using g01fef. This routine allows you to set the required accuracy.

## 10Example

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.

### 10.1Program Text

Program Text (g01fbfe.f90)

### 10.2Program Data

Program Data (g01fbfe.d)

### 10.3Program Results

Program Results (g01fbfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017