# NAG FL Interfaceg01fbf (inv_​cdf_​students_​t)

## 1Purpose

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

## 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 <nag.h>
 double g01fbf_ (const char *tail, const double *p, const double *df, Integer *ifail, const Charlen length_tail)
The routine may be called by the names g01fbf or nagf_stat_inv_cdf_students_t.

## 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 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}$Integer Input/Output
On entry: ifail must be set to $0$, . If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value 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 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).
Errors or warnings detected by the routine:
Note: in some cases g01fbf may return useful information.
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 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface 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.

### 9.1Internal Changes

Internal changes have been made to this routine as follows:
• At Mark 27: The algorithm underlying this routine has been altered to improve the accuracy in cases where ${\mathbf{df}}<3$.
For details of all known issues which have been reported for the NAG Library please refer to the Known Issues.

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