Main Content

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.

More About

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=F1(p|ν)={x:F(x|ν)=p},

where

p=F(x|ν)=0xt(ν2)/2et/22ν/2Γ(ν/2)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].

For more information, see Chi-Square Distribution.

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.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a