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_noncentral (g01gb)

## Purpose

nag_stat_prob_students_t_noncentral (g01gb) returns the lower tail probability for the noncentral Student's $t$-distribution.

## Syntax

[result, ifail] = g01gb(t, df, delta, 'tol', tol, 'maxit', maxit)
[result, ifail] = nag_stat_prob_students_t_noncentral(t, df, delta, 'tol', tol, 'maxit', maxit)
Note: the interface to this routine has changed since earlier releases of the toolbox:
 At Mark 23: tol was made optional (default 0)

## Description

The lower tail probability of the noncentral Student's $t$-distribution with $\nu$ degrees of freedom and noncentrality parameter $\delta$, $P\left(T\le t:\nu \text{;}\delta \right)$, is defined by
 $PT≤t:ν;δ=Cν∫0∞ 12π∫-∞ αu-δe-x2/2dx uν-1e-u2/2du, ν>0.0$
with
 $Cν=1Γ 12ν 2ν- 2/2 , α=tν.$
The probability is computed in one of two ways.
(i) When $t=0.0$, the relationship to the normal is used:
 $PT≤t:ν;δ=12π∫δ∞e-u2/2du.$
(ii) Otherwise the series expansion described in Equation 9 of Amos (1964) is used. This involves the sums of confluent hypergeometric functions, the terms of which are computed using recurrence relationships.

## References

Amos D E (1964) Representations of the central and non-central $t$-distributions Biometrika 51 451–458

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{t}$ – double scalar
$t$, the deviate from the Student's $t$-distribution with $\nu$ degrees of freedom.
2:     $\mathrm{df}$ – double scalar
$\nu$, the degrees of freedom of the Student's $t$-distribution.
Constraint: ${\mathbf{df}}\ge 1.0$.
3:     $\mathrm{delta}$ – double scalar
$\delta$, the noncentrality argument of the Students $t$-distribution.

### Optional Input Parameters

1:     $\mathrm{tol}$ – double scalar
Default: $0.0$
The absolute accuracy required by you in the results. If nag_stat_prob_students_t_noncentral (g01gb) is entered with tol greater than or equal to $1.0$ or less than  (see nag_machine_precision (x02aj)), then the value of  is used instead.
2:     $\mathrm{maxit}$int64int32nag_int scalar
Default: $100$. See Further Comments for further comments.
The maximum number of terms that are used in each of the summations.
Constraint: ${\mathbf{maxit}}\ge 1$.

### Output Parameters

1:     $\mathrm{result}$ – double scalar
The result of the function.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{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 on exit ${\mathbf{ifail}}\ne {\mathbf{0}}$, then nag_stat_prob_students_t_noncentral (g01gb) returns $0.0$.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{df}}<1.0$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{maxit}}<1$.
${\mathbf{ifail}}=3$
One of the series has failed to converge. Reconsider the requested tolerance and/or maximum number of iterations.
${\mathbf{ifail}}=4$
The probability is too small to calculate accurately.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

The series described in Amos (1964) are summed until an estimated upper bound on the contribution of future terms to the probability is less than tol. There may also be some loss of accuracy due to calculation of gamma functions.

The rate of convergence of the series depends, in part, on the quantity ${t}^{2}/\left({t}^{2}+\nu \right)$. The smaller this quantity the faster the convergence. Thus for large $t$ and small $\nu$ the convergence may be slow. If $\nu$ is an integer then one of the series to be summed is of finite length.
If two tail probabilities are required then the relationship of the $t$-distribution to the $F$-distribution can be used:
 $F=T2,λ=δ2,ν1=1 and ν2=ν,$
and a call made to nag_stat_prob_f_noncentral (g01gd).
Note that nag_stat_prob_students_t_noncentral (g01gb) only allows degrees of freedom greater than or equal to $1$ although values between $0$ and $1$ are theoretically possible.

## Example

This example reads values from, and degrees of freedom for, and noncentrality arguments of the noncentral Student's $t$-distributions, calculates the lower tail probabilities and prints all these values until the end of data is reached.
```function g01gb_example

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

t     = [ -1.528   -0.188   1.138];
df    = [ 20        7.5    45    ];
delta = [  2        1       0    ];
p     = t;

fprintf('     t       df    delta     p\n');
for j = 1:numel(t)
[p(j), ifail] = g01gb( ...
t(j), df(j), delta(j));
end

fprintf('%8.3f%8.3f%8.3f%8.4f\n', [t; df; delta; p]);

```
```g01gb example results

t       df    delta     p
-1.528  20.000   2.000  0.0003
-0.188   7.500   1.000  0.1189
1.138  45.000   0.000  0.8694
```