Main Content

chi2inv

Chi-square inverse cumulative distribution function

Description

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.

example

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

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

expand all

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

Version History

Introduced before R2006a