scipy.special.chndtr#
- scipy.special.chndtr(x, df, nc, out=None) = <ufunc 'chndtr'>#
Non-central chi square cumulative distribution function
The cumulative distribution function is given by:
\[P(\chi^{\prime 2} \vert \nu, \lambda) =\sum_{j=0}^{\infty} e^{-\lambda /2} \frac{(\lambda /2)^j}{j!} P(\chi^{\prime 2} \vert \nu + 2j),\]where \(\nu > 0\) is the degrees of freedom (
df
) and \(\lambda \geq 0\) is the non-centrality parameter (nc
).- Parameters:
- xarray_like
Upper bound of the integral; must satisfy
x >= 0
- dfarray_like
Degrees of freedom; must satisfy
df > 0
- ncarray_like
Non-centrality parameter; must satisfy
nc >= 0
- outndarray, optional
Optional output array for the function results
- Returns:
- xscalar or ndarray
Value of the non-central chi square cumulative distribution function.
See also
Notes
The noncentral chi squared distribution is also available in
scipy.stats.ncx2
.scipy.stats.ncx2.cdf
is equivalent tochndtr
.This function wraps routines from the Boost Math C++ library [1].
References
[1]The Boost Developers. “Boost C++ Libraries”. https://www.boost.org/.
Examples
>>> import numpy as np >>> import scipy.special as sc
Compute the noncentral chi squared distribution CDF at one point.
>>> x = 4.0 >>> df = 1.0 >>> nc = 5.0 >>> sc.chndtr(x, df, nc) 0.40667858759710945
Plot the noncentral chi squared distribution CDF for different parameters.
>>> import matplotlib.pyplot as plt >>> x = np.linspace(0, 40, 1000) >>> plt.plot(x, sc.chndtr(x, 1, 5), label=r"$df=1,\ nc=5$") >>> plt.plot(x, sc.chndtr(x, 5, 10), label=r"$df=5,\ nc=10$") >>> plt.legend() >>> plt.show()