Categories &

Functions List

Function Reference: nctpdf

statistics: y = nctpdf (x, df, mu)

Noncentral t-probability density function (PDF).

For each element of x, compute the probability density function (PDF) of the noncentral t-distribution with df degrees of freedom and noncentrality parameter mu. The size of y is the common size of x, df, and mu. A scalar input functions as a constant matrix of the same size as the other inputs.

Further information about the noncentral t-distribution can be found at https://en.wikipedia.org/wiki/Noncentral_t-distribution

See also: nctcdf, nctinv, nctrnd, nctstat, tpdf

Source Code: nctpdf

Example: 1

Plot various PDFs from the noncentral T distribution

 x = -5:0.01:10;
 y1 = nctpdf (x, 1, 0);
 y2 = nctpdf (x, 4, 0);
 y3 = nctpdf (x, 1, 2);
 y4 = nctpdf (x, 4, 2);
 plot (x, y1, '-r', x, y2, '-g', x, y3, '-k', x, y4, '-m')
 grid on
 xlim ([-5, 10])
 ylim ([0, 0.4])
 legend ({'df = 1, μ = 0', 'df = 4, μ = 0', ...
          'df = 1, μ = 2', 'df = 4, μ = 2'}, 'location', 'northeast')
 title ('Noncentral T PDF')
 xlabel ('values in x')
 ylabel ('density')
plotted figure

Example: 2

Compare the noncentral T PDF with MU = 1 to the T PDF with the same number of degrees of freedom (10).

 x = -5:0.1:5;
 y1 = nctpdf (x, 10, 1);
 y2 = tpdf (x, 10);
 plot (x, y1, '-', x, y2, '-');
 grid on
 xlim ([-5, 5])
 ylim ([0, 0.4])
 legend ({'Noncentral χ^2(4,2)', 'χ^2(4)'}, 'location', 'northwest')
 title ('Noncentral T vs T PDFs')
 xlabel ('values in x')
 ylabel ('density')
plotted figure