# tinv

Student's t inverse cumulative distribution function

## Syntax

``x = tinv(p,nu)``

## Description

example

````x = tinv(p,nu)` returns the inverse cumulative distribution function (icdf) of the Student's t distribution evaluated at the probability values in `p` using the corresponding degrees of freedom in `nu`.```

## Examples

collapse all

Find the 95th percentile of the Student's t distribution with `50` degrees of freedom.

```p = .95; nu = 50; x = tinv(p,nu)```
```x = 1.6759 ```

Compute the 99th percentile of the Student's t distribution for `1` to `6` degrees of freedom.

`percentile = tinv(0.99,1:6)`
```percentile = 1×6 31.8205 6.9646 4.5407 3.7469 3.3649 3.1427 ```

Find a 95% confidence interval estimating the mean of a population by using `tinv`.

Generate a random sample of size `100` drawn from a normal population with mean `10` and standard deviation `2`.

```mu = 10; sigma = 2; n = 100; rng default % For reproducibility x = normrnd(mu,sigma,n,1);```

Compute the sample mean, standard error, and degrees of freedom.

```xbar = mean(x); se = std(x)/sqrt(n); nu = n - 1;```

Find the upper and lower confidence bounds for the `95%` confidence interval.

```conf = 0.95; alpha = 1 - conf; pLo = alpha/2; pUp = 1 - alpha/2;```

Compute the critical values for the confidence bounds.

`crit = tinv([pLo pUp], nu);`

Determine the confidence interval for the population mean.

`ci = xbar + crit*se`
```ci = 1×2 9.7849 10.7075 ```

This confidence interval is the same as the `ci` value returned by a `t` test of a null hypothesis that the sample comes from a normal population with mean `mu`.

```[h,p,ci2] = ttest(x,mu,'Alpha',alpha); ci2```
```ci2 = 2×1 9.7849 10.7075 ```

## Input Arguments

collapse all

Probability values at which to evaluate the icdf, specified as a scalar value or an array of scalar values, where each element is in the range `[0,1]`.

• To evaluate the icdf at multiple values, specify `p` using an array.

• To evaluate the icdfs of multiple distributions, specify `nu` using an array.

If either or both of the input arguments `p` and `nu` are arrays, then the array sizes must be the same. In this case, `tinv` expands each scalar input into a constant array of the same size as the array inputs. Each element in `x` is the icdf value of the distribution specified by the corresponding element in `nu`, evaluated at the corresponding probability in `p`.

Example: `[0.1 0.5 0.9]`

Data Types: `single` | `double`

Degrees of freedom for the Student's t distribution, specified as a positive scalar value or an array of positive scalar values.

• To evaluate the icdf at multiple values, specify `p` using an array.

• To evaluate the icdfs of multiple distributions, specify `nu` using an array.

If either or both of the input arguments `p` and `nu` are arrays, then the array sizes must be the same. In this case, `tinv` expands each scalar input into a constant array of the same size as the array inputs. Each element in `x` is the icdf value of the distribution specified by the corresponding element in `nu`, evaluated at the corresponding probability in `p`.

Example: `[9 19 49 99]`

Data Types: `single` | `double`

## Output Arguments

collapse all

icdf values evaluated at the probabilities in `p`, returned as a scalar value or an array of scalar values. `x` is the same size as `p` and `nu` after any necessary scalar expansion. Each element in `x` is the icdf value of the distribution specified by the corresponding element in `nu`, evaluated at the corresponding probability in `p`.

collapse all

### Student’s t icdf

The Student's t distribution is a one-parameter family of curves. The parameter ν is the degrees of freedom. The Student's t distribution has zero mean.

The t inverse function is defined in terms of the Student's t cdf as

`$x={F}^{-1}\left(p|\nu \right)=\left\{x:F\left(x|\nu \right)=p\right\},$`

where

`$p=F\left(x|\nu \right)={\int }_{-\infty }^{x}\frac{\Gamma \left(\frac{\nu +1}{2}\right)}{\Gamma \left(\frac{\nu }{2}\right)}\frac{1}{\sqrt{\nu \pi }}\frac{1}{{\left(1+\frac{{t}^{2}}{\nu }\right)}^{\frac{\nu +1}{2}}}dt,$`

ν is the degrees of freedom, and Γ( · ) is the Gamma function. The result x is the solution of the integral equation where you supply the probability p.

## Alternative Functionality

• `tinv` is a function specific to the Student's t distribution. Statistics and Machine Learning Toolbox™ also offers the generic function `icdf`, which supports various probability distributions. To use `icdf`, specify the probability distribution name and its parameters. Note that the distribution-specific function `tinv` is faster than the generic function `icdf`.