ncx2pdf
Noncentral chi-squared probability distribution function (PDF).
For each element of x, compute the probability density function (PDF) of the noncentral chi-squared distribution with df degrees of freedom and noncentrality parameter lambda. The size of y is the common size of x, df, and lambda. A scalar input functions as a constant matrix of the same size as the other inputs.
Further information about the noncentral chi-squared distribution can be found at https://en.wikipedia.org/wiki/Noncentral_chi-squared_distribution
See also: ncx2cdf, ncx2inv, ncx2rnd, ncx2stat, chi2pdf
Source Code: ncx2pdf
## Plot various PDFs from the noncentral chi-squared distribution x = 0:0.1:10; y1 = ncx2pdf (x, 2, 1); y2 = ncx2pdf (x, 2, 2); y3 = ncx2pdf (x, 2, 3); y4 = ncx2pdf (x, 4, 1); y5 = ncx2pdf (x, 4, 2); y6 = ncx2pdf (x, 4, 3); plot (x, y1, "-r", x, y2, "-g", x, y3, "-k", ... x, y4, "-m", x, y5, "-c", x, y6, "-y") grid on xlim ([0, 10]) ylim ([0, 0.32]) legend ({"df = 2, λ = 1", "df = 2, λ = 2", ... "df = 2, λ = 3", "df = 4, λ = 1", ... "df = 4, λ = 2", "df = 4, λ = 3"}, "location", "northeast") title ("Noncentral chi-squared PDF") xlabel ("values in x") ylabel ("density") |
## Compare the noncentral chi-squared PDF with LAMBDA = 2 to the ## chi-squared PDF with the same number of degrees of freedom (4). x = 0:0.1:10; y1 = ncx2pdf (x, 4, 2); y2 = chi2pdf (x, 4); plot (x, y1, "-", x, y2, "-"); grid on xlim ([0, 10]) ylim ([0, 0.32]) legend ({"Noncentral T(10,1)", "T(10)"}, "location", "northwest") title ("Noncentral chi-squared vs chi-squared PDFs") xlabel ("values in x") ylabel ("density") |