Documentation

# tcdf

Student's t cumulative distribution function

## Syntax

```p = tcdf(x,nu) p = tcdf(x,nu,'upper') ```

## Description

`p = tcdf(x,nu)` returns the cumulative distribution function (cdf) of the Student's t distribution at each of the values in `x` using the corresponding degrees of freedom in `nu`. `x` and `nu` can be vectors, matrices, or multidimensional arrays that all have the same size. A scalar input is expanded to a constant array with the same dimensions as the other inputs.

`p = tcdf(x,nu,'upper')` returns the complement of the Student’s t cdf at each value in `x`, using an algorithm that more accurately computes the extreme upper tail probabilities.

## Examples

collapse all

```mu = 1; % Population mean sigma = 2; % Population standard deviation n = 100; % Sample size rng default % For reproducibility x = normrnd(mu,sigma,n,1); % Random sample from population xbar = mean(x); % Sample mean s = std(x); % Sample standard deviation t = (xbar - mu)/(s/sqrt(n))```
```t = 1.0589 ```
`p = 1-tcdf(t,n-1) % Probability of larger t-statistic`
```p = 0.1461 ```

This probability is the same as the p value returned by a t test of the null hypothesis that the sample comes from a normal population with mean $\mu$

`[h,ptest] = ttest(x,mu,0.05,'right')`
```h = 0 ```
```ptest = 0.1461 ```

collapse all

### Student’s t cdf

The cumulative distribution function (cdf) of Student’s t distribution is

`$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$`

where ν is the degrees of freedom and Γ( · ) is the Gamma function. The result p is the probability that a single observation from the t distribution with ν degrees of freedom will fall in the interval [–∞, x].