# chi2inv

Chi-square inverse cumulative distribution function

## Description

example

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

## Examples

collapse all

Find the 95th percentile for the chi-square distribution with 10 degrees of freedom.

x = chi2inv(0.95,10)
x = 18.3070

If you generate random numbers from this chi-square distribution, you would observe numbers greater than 18.3 only 5% of the time.

Compute the medians of the chi-square distributions with degrees of freedom one through six.

x = chi2inv(0.50,1:6)
x = 1×6

0.4549    1.3863    2.3660    3.3567    4.3515    5.3481

## Input Arguments

collapse all

Probability values at which to evaluate the icdf, specified as a scalar value or an array of scalar values, where each element is in the range [0,1].

• To evaluate the icdf at multiple values, specify p using an array.

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

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

Example: [0.1,0.5,0.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 icdf at multiple values, specify p using an array.

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

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

Example: [9 19 49 99]

Data Types: single | double

## Output Arguments

collapse all

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

collapse all

### Chi-Square icdf

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

The icdf of the chi-square distribution is

$x={F}^{-1}\left(p|\nu \right)=\left\{x:F\left(x|\nu \right)=p\right\},$

where

$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,$

ν 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

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

## Version History

Introduced before R2006a