Main Content

ncx2cdf

Noncentral chi-square cumulative distribution function

Description

p = ncx2cdf(x,nu,delta) returns the cumulative distribution function (cdf) of the noncentral chi-square distribution with nu numerator degrees of freedom and the noncentrality parameter delta, evaluated at the values in x.

example

p = ncx2cdf(x,nu,delta,"upper") returns the complement of the noncentral chi-square cdf, evaluated at the values in x, using an algorithm that more accurately computes the extreme upper-tail probabilities as compared to subtracting the lower-tail value from 1.

example

Examples

collapse all

Compute the cumulative distribution function (cdf) for the noncentral chi-square distribution with 4 degrees of freedom and the noncentrality parameter delta=2, evaluated at the values in x. Plot the result together with the cdf of the chi-square distribution with the same number of degrees of freedom.

x = 0:0.1:10;
p1 = ncx2cdf(x,4,2);
p2 = chi2cdf(x,4);
plot(x,p1,"b-",x,p2,"r:")
grid on
xlabel("x")
ylabel("p")
legend(["Noncentral chi-square CDF" "Chi-square CDF"],Location="southeast")

Figure contains an axes object. The axes object with xlabel x, ylabel p contains 2 objects of type line. These objects represent Noncentral chi-square CDF, Chi-square CDF.

Determine the probability of sampling a number greater than 100 from the noncentral chi-square distribution with 4 degrees of freedom and the noncentrality parameter delta=2. To determine the probability, calculate the probability of sampling a number less than or equal to 100 and subtract the result from 1.

p1 = 1 - ncx2cdf(100,4,2)
p1 = 
0

The probability of sampling a number less than or equal to 100 is so close to 1 that subtracting the result from 1 gives 0.

To approximate the extreme upper-tail probability with greater precision, compute the complement of the noncentral chi-square cdf directly.

p2 = ncx2cdf(100,4,2,"upper")
p2 = 
8.3955e-17

The output indicates a small probability of sampling a number greater than 100.

Input Arguments

collapse all

Values at which to evaluate the noncentral chi-square cdf, specified as a numeric scalar or an array of numeric scalars.

To evaluate the cdf at multiple values, specify x as an array. To evaluate the cdfs of multiple distributions, specify either nu or delta (or both) using arrays. If one or more of the input arguments x, nu, and delta are arrays, then the array sizes must be the same. In this case, ncx2cdf 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 elements in nu and delta, evaluated at the corresponding element in x.

Data Types: single | double

Degrees of freedom, specified as a positive scalar or an array of positive scalars.

To evaluate the cdf at multiple values, specify x as an array. To evaluate the cdfs of multiple distributions, specify either nu or delta (or both) using arrays. If one or more of the input arguments x, nu, and delta are arrays, then the array sizes must be the same. In this case, ncx2cdf 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 elements in nu and delta, evaluated at the corresponding element in x.

Data Types: single | double

Noncentrality parameter, specified as a nonnegative scalar or an array of nonnegative scalars.

To evaluate the cdf at multiple values, specify x as an array. To evaluate the cdfs of multiple distributions, specify either nu or delta (or both) using arrays. If one or more of the input arguments x, nu, and delta are arrays, then the array sizes must be the same. In this case, ncx2cdf 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 elements in nu and delta, evaluated at the corresponding element in x.

Data Types: single | double

Output Arguments

collapse all

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

More About

collapse all

Alternative Functionality

  • ncx2cdf is a function specific to the noncentral 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 ncx2cdf is faster than the generic function cdf.

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

References

[1] Johnson, N., and S. Kotz. Distributions in Statistics: Continuous Univariate Distributions-2. Hoboken, NJ: John Wiley & Sons, Inc., 1970.

Extended Capabilities

expand all

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

Version History

Introduced before R2006a

expand all