# NAG FL Interfaceg01tbf (inv_​cdf_​students_​t_​vector)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

g01tbf returns a number of deviates associated with given probabilities of Student's $t$-distribution with real degrees of freedom.

## 2Specification

Fortran Interface
 Subroutine g01tbf ( tail, lp, p, ldf, df, t,
 Integer, Intent (In) :: ltail, lp, ldf Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: ivalid(*) Real (Kind=nag_wp), Intent (In) :: p(lp), df(ldf) Real (Kind=nag_wp), Intent (Out) :: t(*) Character (1), Intent (In) :: tail(ltail)
#include <nag.h>
 void g01tbf_ (const Integer *ltail, const char tail[], const Integer *lp, const double p[], const Integer *ldf, const double df[], double t[], Integer ivalid[], Integer *ifail, const Charlen length_tail)
The routine may be called by the names g01tbf or nagf_stat_inv_cdf_students_t_vector.

## 3Description

The deviate, ${t}_{{p}_{i}}$ associated with the lower tail probability, ${p}_{i}$, of the Student's $t$-distribution with ${\nu }_{i}$ degrees of freedom is defined as the solution to
 $P( Ti < tpi :νi) = pi = Γ ((νi+1)/2) νiπ Γ (νi/2) ∫ -∞ tpi (1+ Ti2 νi ) - (νi+1) / 2 d Ti , νi ≥ 1 ; ​ -∞ < tpi < ∞ .$
For ${\nu }_{i}=1$ or $2$ the integral equation is easily solved for ${t}_{{p}_{i}}$.
For other values of ${\nu }_{i}<3$ a transformation to the beta distribution is used and the result obtained from g01fef.
For ${\nu }_{i}\ge 3$ an inverse asymptotic expansion of Cornish–Fisher type is used. The algorithm is described by Hill (1970).
The input arrays to this routine are designed to allow maximum flexibility in the supply of vector arguments by re-using elements of any arrays that are shorter than the total number of evaluations required. See Section 2.6 in the G01 Chapter Introduction for further information.

## 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{ltail}$Integer Input
On entry: the length of the array tail.
Constraint: ${\mathbf{ltail}}>0$.
2: $\mathbf{tail}\left({\mathbf{ltail}}\right)$Character(1) array Input
On entry: indicates which tail the supplied probabilities represent. For , for $\mathit{i}=1,2,\dots ,\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ltail}},{\mathbf{lp}},{\mathbf{ldf}}\right)$:
${\mathbf{tail}}\left(j\right)=\text{'L'}$
The lower tail probability, i.e., ${p}_{i}=P\left({T}_{i}\le {t}_{{p}_{i}}:{\nu }_{i}\right)$.
${\mathbf{tail}}\left(j\right)=\text{'U'}$
The upper tail probability, i.e., ${p}_{i}=P\left({T}_{i}\ge {t}_{{p}_{i}}:{\nu }_{i}\right)$.
${\mathbf{tail}}\left(j\right)=\text{'C'}$
The two tail (confidence interval) probability,
i.e., ${p}_{i}=P\left({T}_{i}\le |{t}_{{p}_{i}}|:{\nu }_{i}\right)-P\left({T}_{i}\le -|{t}_{{p}_{i}}|:{\nu }_{i}\right)$.
${\mathbf{tail}}\left(j\right)=\text{'S'}$
The two tail (significance level) probability,
i.e., ${p}_{i}=P\left({T}_{i}\ge |{t}_{{p}_{i}}|:{\nu }_{i}\right)+P\left({T}_{i}\le -|{t}_{{p}_{i}}|:{\nu }_{i}\right)$.
Constraint: ${\mathbf{tail}}\left(\mathit{j}\right)=\text{'L'}$, $\text{'U'}$, $\text{'C'}$ or $\text{'S'}$, for $\mathit{j}=1,2,\dots ,{\mathbf{ltail}}$.
3: $\mathbf{lp}$Integer Input
On entry: the length of the array p.
Constraint: ${\mathbf{lp}}>0$.
4: $\mathbf{p}\left({\mathbf{lp}}\right)$Real (Kind=nag_wp) array Input
On entry: ${p}_{i}$, the probability of the required Student's $t$-distribution as defined by tail with ${p}_{i}={\mathbf{p}}\left(j\right)$, .
Constraint: $0.0<{\mathbf{p}}\left(\mathit{j}\right)<1.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{lp}}$.
5: $\mathbf{ldf}$Integer Input
On entry: the length of the array df.
Constraint: ${\mathbf{ldf}}>0$.
6: $\mathbf{df}\left({\mathbf{ldf}}\right)$Real (Kind=nag_wp) array Input
On entry: ${\nu }_{i}$, the degrees of freedom of the Student's $t$-distribution with ${\nu }_{i}={\mathbf{df}}\left(j\right)$, .
Constraint: ${\mathbf{df}}\left(\mathit{j}\right)\ge 1.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{ldf}}$.
7: $\mathbf{t}\left(*\right)$Real (Kind=nag_wp) array Output
Note: the dimension of the array t must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ltail}},{\mathbf{lp}},{\mathbf{ldf}}\right)$.
On exit: ${t}_{{p}_{i}}$, the deviates for the Student's $t$-distribution.
8: $\mathbf{ivalid}\left(*\right)$Integer array Output
Note: the dimension of the array ivalid must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ltail}},{\mathbf{lp}},{\mathbf{ldf}}\right)$.
On exit: ${\mathbf{ivalid}}\left(i\right)$ indicates any errors with the input arguments, with
${\mathbf{ivalid}}\left(i\right)=0$
No error.
${\mathbf{ivalid}}\left(i\right)=1$
On entry, invalid value supplied in tail when calculating ${t}_{{p}_{i}}$.
${\mathbf{ivalid}}\left(i\right)=2$
On entry, ${p}_{i}\le 0.0$, or, ${p}_{i}\ge 1.0$.
${\mathbf{ivalid}}\left(i\right)=3$
On entry, ${\nu }_{i}<1.0$.
${\mathbf{ivalid}}\left(i\right)=4$
The solution has failed to converge. The result returned should represent an approximation to the solution.
9: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{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).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, at least one value of tail, p or df was invalid, or the solution failed to converge.
${\mathbf{ifail}}=2$
On entry, $\text{array size}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ltail}}>0$.
${\mathbf{ifail}}=3$
On entry, $\text{array size}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lp}}>0$.
${\mathbf{ifail}}=4$
On entry, $\text{array size}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldf}}>0$.
${\mathbf{ifail}}=-99$
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

g01tbf is not threaded in any implementation.

The value ${t}_{{p}_{i}}$ may be calculated by using a transformation to the beta distribution and calling g01tef. 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 (g01tbfe.f90)

### 10.2Program Data

Program Data (g01tbfe.d)

### 10.3Program Results

Program Results (g01tbfe.r)