Function Reference: tpdf

statistics: p = tpdf (x, df)

Student’s T probability density function (PDF).

For each element of x, compute the probability density function (PDF) of the Student’s T distribution with df degrees of freedom. The size of y is the common size of x and df. A scalar input functions as a constant matrix of the same size as the other input.

Further information about the Student’s T distribution can be found at https://en.wikipedia.org/wiki/Student%27s_t-distribution

See also: tcdf, tpdf, trnd, tstat

Source Code: tpdf

Example: 1

 

 ## Plot various PDFs from the Student's T distribution
 x = -5:0.01:5;
 y1 = tpdf (x, 1);
 y2 = tpdf (x, 2);
 y3 = tpdf (x, 5);
 y4 = tpdf (x, Inf);
 plot (x, y1, "-b", x, y2, "-g", x, y3, "-r", x, y4, "-m")
 grid on
 xlim ([-5, 5])
 ylim ([0, 0.41])
 legend ({"df = 1", "df = 2", ...
          "df = 5", 'df = \infty'}, "location", "northeast")
 title ("Student's T PDF")
 xlabel ("values in x")
 ylabel ("density")

                    
plotted figure