scipy.special.chndtrix#

scipy.special.chndtrix(p, df, nc, out=None) = <wrapped_ufunc 'chndtrix'>#

Inverse to chndtr vs x.

Calculated using a search to find a value for x that produces the desired value of p.

Parameters:
parray_like

Probability; must satisfy 0 <= p < 1

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 so that the probability a non-central Chi square random variable with df degrees of freedom and non-centrality, nc, is less than or equal to x equals p.

See also

chndtr

Noncentral chi-squared distribution CDF

chndtridf

inverse of chndtr with respect to df

chndtrinc

inverse of chndtr with respect to nc

scipy.stats.ncx2

Non-central chi-squared distribution

Notes

The noncentral chi squared distribution is also available in scipy.stats.ncx2. scipy.stats.ncx2.ppf is equivalent to chndtrix.

This function wraps routines from the Boost Math C++ library [1].

Array API Standard Support

chndtrix has support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

✅

n/a

CuPy

n/a

⛔

PyTorch

✅

⛔

JAX

✅

⛔

Dask

✅

n/a

For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support out, but typically none of the other ufunc kwargs. out is typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend. out is never supported for JAX because JAX arrays are immutable. chndtrix does not currently support out for the PyTorch backend.

See Support for the array API standard for more information.

References

[1]

The Boost Developers. “Boost C++ Libraries”. https://www.boost.org/.

Examples

>>> from scipy.special import chndtrix, chndtr

Compute the noncentral chi squared distribution CDF at one point. >>> x, df, nc = 3, 5, 10 >>> p = chndtr(x, df, nc)

chndtrix is the inverse of chndtr with respect to x:

>>> chndtrix(p, df, nc)
3.0