Function Reference: chi2cdf

statistics: p = chi2cdf (x, df)
statistics: p = chi2cdf (x, df, "upper")

Chi-squared cumulative distribution function (CDF).

For each element of x, compute the cumulative distribution function (CDF) of the chi-squared distribution with df degrees of freedom. The chi-squared density function with df degrees of freedom is the same as a gamma density function with parameters df/2 and 2.

The size of p is the common size of x and df. A scalar input functions as a constant matrix of the same size as the other input.

p = chi2cdf (x, df, "upper") computes the upper tail probability of the chi-squared distribution with df degrees of freedom, at the values in x.

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

See also: chi2inv, chi2pdf, chi2rnd, chi2stat

Source Code: chi2cdf

Example: 1

 

 ## Plot various CDFs from the chi-squared distribution
 x = 0:0.01:8;
 p1 = chi2cdf (x, 1);
 p2 = chi2cdf (x, 2);
 p3 = chi2cdf (x, 3);
 p4 = chi2cdf (x, 4);
 p5 = chi2cdf (x, 6);
 p6 = chi2cdf (x, 9);
 plot (x, p1, "-b", x, p2, "-g", x, p3, "-r", ...
       x, p4, "-c", x, p5, "-m", x, p6, "-y")
 grid on
 xlim ([0, 8])
 legend ({"df = 1", "df = 2", "df = 3", ...
          "df = 4", "df = 6", "df = 9"}, "location", "southeast")
 title ("Chi-squared CDF")
 xlabel ("values in x")
 ylabel ("probability")

                    
plotted figure