Main Content

tcdf

Student's t cumulative distribution function

Description

p = tcdf(x,nu) returns the cumulative distribution function (cdf) of the Student's t distribution with nu degrees of freedom, evaluated at the values in x.

example

p = tcdf(x,nu,'upper') returns the complement of the cdf, evaluated at the values in x with nu degrees of freedom, using an algorithm that more accurately computes the extreme upper-tail probabilities than subtracting the lower tail value from 1.

example

Examples

collapse all

Generate a random sample of size 100 from a normally distributed population with mean 1 and standard deviation 2.

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

Compute the sample mean, sample standard deviation, and t-score of the sample.

xbar = mean(x);
s = std(x);
t = (xbar-mu)/(s/sqrt(n))
t = 
1.0589

Use tcdf to compute the probability of a sample of size 100 having a larger t-score than the t-score of the sample.

p = 1-tcdf(t,n-1)
p = 
0.1461

This probability is the same as the p value returned by a t test with null hypothesis that the sample comes from a normal population with mean 1 and alternative hypothesis that the mean is greater than 1.

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

Determine the probability that an observation from the Student's t distribution with degrees of freedom 99 falls on the interval [10 Inf].

p1 = 1 - tcdf(10,99)
p1 = 
0

tcdf(10,99) is nearly 1, so p1 becomes 0. Specify 'upper' so that tcdf computes the extreme upper-tail probabilities more accurately.

p2 = tcdf(10,99,'upper')
p2 = 
5.4699e-17

You can also use 'upper' to compute a right-tailed p-value.

Input Arguments

collapse all

Values at which to evaluate the cdf, specified as a scalar value or an array of scalar values.

  • To evaluate the cdf at multiple values, specify x using an array.

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

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

Example: [-1,0,3,4]

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 cdf at multiple values, specify x using an array.

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

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

Example: [9,19,49,99]

Data Types: single | double

Output Arguments

collapse all

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

More About

collapse all

Student’s t cdf

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 cdf of the Student’s t distribution is

p=F(x|ν)=xΓ(ν+12)Γ(ν2)1νπ1(1+t2ν)ν+12dt,

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 falls in the interval [–∞, x].

For more information, see Student's t Distribution.

Alternative Functionality

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

  • Use the Probability Distribution Function app to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a