# chi2cdf

Chi-square cumulative distribution function

## Description

example

p = chi2cdf(x,nu) returns the cumulative distribution function (cdf) of the chi-square distribution with degrees of freedom nu, evaluated at the values in x.

example

p = chi2cdf(x,nu,'upper') returns the complement of the cdf, evaluated at the values in x with degrees of freedom nu, using an algorithm that more accurately computes the extreme upper-tail probabilities than subtracting the lower tail value from 1.

## Examples

collapse all

Compute the probability that an observation from the chi-square distribution with 5 degrees of freedom is in the interval [0 3].

p1 = chi2cdf(3,5)
p1 = 0.3000

Compute the probability that an observation from the chi-square distributions with degrees of freedom 1 through 5 is in the interval [0 3].

p2 = chi2cdf(3,1:5)
p2 = 1×5

0.9167    0.7769    0.6084    0.4422    0.3000

The mean of the chi-square distribution is equal to the degrees of freedom. Compute the probability that an observation is in the interval [0 nu] for degrees of freedom 1 through 6.

nu = 1:6;
x = nu;
p3 = chi2cdf(x,nu)
p3 = 1×6

0.6827    0.6321    0.6084    0.5940    0.5841    0.5768

As the degrees of freedom increase, the probability that an observation from a chi-square distribution with degrees of freedom nu is less than the mean value approaches 0.5.

Determine the probability that an observation from the chi-square distribution with 3 degrees of freedom is in on the interval [100 Inf].

p1 = 1 - chi2cdf(100,3)
p1 = 0

chi2cdf(100,3) is nearly 1, so p1 becomes 0. Specify 'upper' so that chi2cdf computes the extreme upper-tail probabilities more accurately.

p2 = chi2cdf(100,3,'upper')
p2 = 1.5542e-21

## Input Arguments

collapse all

Values at which to evaluate the cdf, specified as a nonnegative scalar value or an array of nonnegative scalar values.

• To evaluate the cdf at multiple values, specify x using an array.

• To evaluate the cdfs of multiple distributions, specify nu using an array.

If either or both of the input arguments x and nu are arrays, then the array sizes must be the same. In this case, chi2cdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding element in nu, evaluated at the corresponding element in x.

Example: [3 4 7 9]

Data Types: single | double

Degrees of freedom for the chi-square distribution, specified as a positive scalar value or an array of positive scalar values.

• To evaluate the cdf at multiple values, specify x using an array.

• To evaluate the cdfs of multiple distributions, specify nu using an array.

If either or both of the input arguments x and nu are arrays, then the array sizes must be the same. In this case, chi2cdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the cdf value of the distribution specified by the corresponding element in nu, evaluated at the corresponding element in x.

Example: [9 19 49 99]

Data Types: single | double

## Output Arguments

collapse all

cdf values evaluated at the values in x, returned as a scalar value or an array of scalar values. p is the same size as x and nu after any necessary scalar expansion. Each element in p is the cdf value of the distribution specified by the corresponding element in nu, evaluated at the corresponding element in x.

collapse all

### Chi-Square cdf

The chi-square distribution is a one-parameter family of curves. The parameter ν is the degrees of freedom.

The cdf of the chi-square distribution is

$p=F\left(x|\nu \right)={\int }_{0}^{x}\frac{{t}^{\left(\nu -2\right)/2}{e}^{-t/2}}{{2}^{\nu /2}\Gamma \left(\nu /2\right)}dt,$

where ν is the degrees of freedom and Γ( · ) is the Gamma function. The result p is the probability that a single observation from the chi-square distribution with ν degrees of freedom falls in the interval [0, x].

## Alternative Functionality

• chi2cdf is a function specific to the chi-square distribution. Statistics and Machine Learning Toolbox™ also offers the generic function cdf, which supports various probability distributions. To use cdf, specify the probability distribution name and its parameters. Note that the distribution-specific function chi2cdf is faster than the generic function cdf.

• Use the Probability Distribution Function app to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.

## Version History

Introduced before R2006a