Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_stat_prob_students_t (g01eb)

## Purpose

nag_stat_prob_students_t (g01eb) returns the lower tail, upper tail or two tail probability for the Student's t$t$-distribution with real degrees of freedom.

## Syntax

[result, ifail] = g01eb(t, df, 'tail', tail)
[result, ifail] = nag_stat_prob_students_t(t, df, 'tail', tail)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: tail now optional (default 'l')
.

## Description

The lower tail probability for the Student's t$t$-distribution with ν$\nu$ degrees of freedom, P(Tt : ν)$P\left(T\le t:\nu \right)$ is defined by:
 t P(T ≤ t : ν) = ( Γ ((ν + 1) / 2) )/( sqrt(πν) Γ(ν / 2) ) ∫ [1 + (T2)/ν] − (ν + 1) / 2 dT,  ν ≥ 1. − ∞
$P (T≤t:ν) = Γ ( (ν+1) / 2 ) πν Γ(ν/2) ∫ -∞ t [ 1+ T2ν ] -(ν+1) / 2 dT , ν≥1 .$
Computationally, there are two situations:
(i) when ν < 20$\nu <20$, a transformation of the beta distribution, Pβ(Bβ : a,b)${P}_{\beta }\left(B\le \beta :a,b\right)$ is used
 P (T ≤ t : ν) = (1/2) Pβ (B ≤ ν/(ν + t2) : ν / 2,(1/2))   when ​ t < 0.0 $P (T≤t:ν) = 12 Pβ ( B≤ ν ν+t2 : ν/2, 12 ) when ​ t<0.0$
or
 P (T ≤ t : ν) = (1/2) + (1/2) Pβ (B ≥ (ν)/(ν + t2) : ν / 2,(1/2))   when ​ t > 0.0 ; $P (T≤t:ν) = 12 + 12 Pβ ( B≥ ν ν+t2 : ν/2, 12 ) when ​ t>0.0 ;$
(ii) when ν20$\nu \ge 20$, an asymptotic normalizing expansion of the Cornish–Fisher type is used to evaluate the probability, see Hill (1970).

## 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
Hill G W (1970) Student's t$t$-distribution Comm. ACM 13(10) 617–619

## Parameters

### Compulsory Input Parameters

1:     t – double scalar
t$t$, the value of the Student's t$t$ variate.
2:     df – double scalar
ν$\nu$, the degrees of freedom of the Student's t$t$-distribution.
Constraint: df1.0${\mathbf{df}}\ge 1.0$.

### Optional Input Parameters

1:     tail – string (length ≥ 1)
Indicates which tail the returned probability should represent.
tail = 'U'${\mathbf{tail}}=\text{'U'}$
The upper tail probability is returned, i.e., P(Tt : ν)$P\left(T\ge t:\nu \right)$.
tail = 'S'${\mathbf{tail}}=\text{'S'}$
The two tail (significance level) probability is returned,
i.e., P(T|t| : ν) + P(T|t| : ν)$P\left(T\ge |t|:\nu \right)+P\left(T\le -|t|:\nu \right)$.
tail = 'C'${\mathbf{tail}}=\text{'C'}$
The two tail (confidence interval) probability is returned,
i.e., P(T|t| : ν)P(T|t| : ν)$P\left(T\le |t|:\nu \right)-P\left(T\le -|t|:\nu \right)$.
tail = 'L'${\mathbf{tail}}=\text{'L'}$
The lower tail probability is returned, i.e., P(Tt : ν)$P\left(T\le t:\nu \right)$.
Default: 'L'$\text{'L'}$
Constraint: tail = 'U'${\mathbf{tail}}=\text{'U'}$, 'S'$\text{'S'}$, 'C'$\text{'C'}$ or 'L'$\text{'L'}$.

None.

### Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
If ${\mathbf{ifail}}\ne {\mathbf{0}}$, then nag_stat_prob_students_t (g01eb) returns 0.0$0.0$.
ifail = 1${\mathbf{ifail}}=1$
 On entry, tail ≠ 'U'${\mathbf{tail}}\ne \text{'U'}$, 'S'$\text{'S'}$, 'C'$\text{'C'}$ or 'L'$\text{'L'}$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, df < 1.0${\mathbf{df}}<1.0$.

## Accuracy

The computed probability should be accurate to five significant places for reasonable probabilities but there will be some loss of accuracy for very low probabilities (less than 1010${10}^{-10}$), see Hastings and Peacock (1975).

The probabilities could also be obtained by using the appropriate transformation to a beta distribution (see Abramowitz and Stegun (1972)) and using nag_stat_prob_beta (g01ee). This function allows you to set the required accuracy.

## Example

```function nag_stat_prob_students_t_example
t = 0.85;
df = 20;
[result, ifail] = nag_stat_prob_students_t(t, df)
```
```

result =

0.7973

ifail =

0

```
```function g01eb_example
t = 0.85;
df = 20;
[result, ifail] = g01eb(t, df)
```
```

result =

0.7973

ifail =

0

```