Main Content

ncx2pdf

Noncentral chi-square probability density function

Description

p = ncx2pdf(x,nu,delta) returns the noncentral chi-square probability density function (pdf) with nu degrees of freedom and the noncentrality parameter delta, evaluated at the values in x.

example

Examples

collapse all

Compute the probability density function (pdf) of a noncentral chi-square distribution with 4 degrees of freedom and the noncentrality parameter delta=2. For comparison, also compute the pdf of a chi-square distribution with the same degrees of freedom.

x = 0:0.1:15;
nu = 4;
delta = 2;
ncx2 = ncx2pdf(x,nu,delta);
chi2 = chi2pdf(x,nu);

Plot the noncentral chi-square pdf and the chi-square pdf on the same figure.

figure
plot(x,ncx2,"b-",LineWidth=2)
hold on
grid on
plot(x,chi2,"r--",Linewidth=2)
xlabel("x")
ylabel("p")
legend("Noncentral chi-square pdf","Chi-square pdf")
hold off

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 pdf, Chi-square pdf.

Input Arguments

collapse all

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

To evaluate the pdf at multiple values, specify x as an array. To evaluate the pdfs 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, ncx2pdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the pdf 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 pdf at multiple values, specify x as an array. To evaluate the pdfs 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, ncx2pdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the pdf 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 pdf at multiple values, specify x as an array. To evaluate the pdfs 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, ncx2pdf expands each scalar input into a constant array of the same size as the array inputs. Each element in p is the pdf 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 pdf values evaluated at the values in x, 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 pdf value of the distribution specified by the corresponding elements in nu and delta, evaluated at the corresponding element in x.

Alternative Functionality

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

  • 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

Version History

Introduced before R2006a

expand all