Student's t cumulative distribution function


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


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.


expand all

Compute Student's t cdf

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 =


p = 1-tcdf(t,n-1) % Probability of larger t-statistic
p =


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 =


ptest =


More About

expand all

Student's t cdf

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


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].

See Also

| | | |

Was this topic helpful?