Categories &

Functions List

Function Reference: nctinv

statistics: x = ncx2inv (p, df, mu)

Inverse of the non-central t-cumulative distribution function (iCDF).

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

nctinv uses Newton’s method to converge to the solution.

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

See also: nctcdf, nctpdf, nctrnd, nctstat, tinv

Source Code: nctinv

Example: 1

 

 ## Plot various iCDFs from the noncentral T distribution
 p = 0.001:0.001:0.999;
 x1 = nctinv (p, 1, 0);
 x2 = nctinv (p, 4, 0);
 x3 = nctinv (p, 1, 2);
 x4 = nctinv (p, 4, 2);
 plot (p, x1, "-r", p, x2, "-g", p, x3, "-k", p, x4, "-m")
 grid on
 ylim ([-5, 5])
 legend ({"df = 1, μ = 0", "df = 4, μ = 0", ...
          "df = 1, μ = 2", "df = 4, μ = 2"}, "location", "northwest")
 title ("Noncentral T iCDF")
 xlabel ("probability")
 ylabel ("values in x")

                    
plotted figure

Example: 2

 

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

 p = 0.001:0.001:0.999;
 x1 = nctinv (p, 10, 1);
 x2 = tinv (p, 10);
 plot (p, x1, "-", p, x2, "-");
 grid on
 ylim ([-5, 5])
 legend ({"Noncentral T(10,1)", "T(10)"}, "location", "northwest")
 title ("Noncentral T vs T quantile functions")
 xlabel ("probability")
 ylabel ("values in x")

                    
plotted figure