Statistics: ncx2cdf

### Function Reference: `ncx2cdf`

statistics: p = ncx2cdf (x, df, lambda)
statistics: p = ncx2cdf (x, df, lambda, `"upper"`)

Noncentral chi-squared cumulative distribution function (CDF).

For each element of x, compute the cumulative distribution function (CDF) of the noncentral chi-squared distribution with df degrees of freedom and noncentrality parameter lambda. The size of p 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.

`p = ncx2cdf (x, df, lambda, "upper")` computes the upper tail probability of the noncentral chi-squared distribution with parameters df and lambda, at the values in x.

Further information about the noncentral chi-squared distribution can be found at https://en.wikipedia.org/wiki/Noncentral_chi-squared_distribution

See also: ncx2inv, ncx2pdf, ncx2rnd, ncx2stat, chi2cdf

Source Code: ncx2cdf

### Example: 1

     ## Plot various CDFs from the noncentral chi-squared distribution
     x = 0:0.1:10;
     p1 = ncx2cdf (x, 2, 1);
     p2 = ncx2cdf (x, 2, 2);
     p3 = ncx2cdf (x, 2, 3);
     p4 = ncx2cdf (x, 4, 1);
     p5 = ncx2cdf (x, 4, 2);
     p6 = ncx2cdf (x, 4, 3);
     plot (x, p1, "-r", x, p2, "-g", x, p3, "-k", ...
           x, p4, "-m", x, p5, "-c", x, p6, "-y")
     grid on
     xlim ([0, 10])
     legend ({"df = 2, λ = 1", "df = 2, λ = 2", ...
              "df = 2, λ = 3", "df = 4, λ = 1", ...
              "df = 4, λ = 2", "df = 4, λ = 3"}, "location", "southeast")
     title ("Noncentral chi-squared CDF")
     xlabel ("values in x")
     ylabel ("probability")

### Example: 2

     ## Compare the noncentral chi-squared CDF with LAMBDA = 2 to the
     ## chi-squared CDF with the same number of degrees of freedom (4).

     x = 0:0.1:10;
     p1 = ncx2cdf (x, 4, 2);
     p2 = chi2cdf (x, 4);
     plot (x, p1, "-", x, p2, "-")
     grid on
     xlim ([0, 10])
     legend ({"Noncentral χ^2(4,2)", "χ^2(4)"}, "location", "northwest")
     title ("Noncentral chi-squared vs chi-squared CDFs")
     xlabel ("values in x")
     ylabel ("probability")