scipy.special.betaincc#

scipy.special.betaincc(a, b, x, out=None) = <ufunc 'betaincc'>#

Complement of the regularized incomplete beta function.

Computes the complement of the regularized incomplete beta function, defined as [1]:

\[\bar{I}_x(a, b) = 1 - I_x(a, b) = 1 - \frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)} \int_0^x t^{a-1}(1-t)^{b-1}dt,\]

for \(0 \leq x \leq 1\).

Parameters:
a, barray_like

Positive, real-valued parameters.

xarray_like

Real-valued such that \(0 \leq x \leq 1\), the upper limit of integration.

outndarray, optional

Optional output array for the function values.

Returns:
scalar or ndarray

Value of the complement of the regularized incomplete beta function.

See also

betainc

regularized incomplete beta function

betaincinv

inverse of the regularized incomplete beta function

betainccinv

inverse of the complement of the regularized incomplete beta function

beta

beta function

scipy.stats.beta

beta distribution

Notes

Added in version 1.11.0.

Like betainc, betaincc(a, b, x) is treated as a two parameter family of functions of a single variable x, rather than as a function of three variables. See the betainc docstring for more info on how this impacts limiting cases.

This function wraps the ibetac routine from the Boost Math C++ library [2].

Array API Standard Support

betaincc 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 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. betaincc does not currently support out for the CuPy and PyTorch backends.

See Support for the array API standard for more information.

References

[1]

NIST Digital Library of Mathematical Functions https://dlmf.nist.gov/8.17

[2]

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

Examples

>>> from scipy.special import betaincc, betainc

The naive calculation 1 - betainc(a, b, x) loses precision when the values of betainc(a, b, x) are close to 1:

>>> 1 - betainc(0.5, 8, [0.9, 0.99, 0.999])
array([2.0574632e-09, 0.0000000e+00, 0.0000000e+00])

By using betaincc, we get the correct values:

>>> betaincc(0.5, 8, [0.9, 0.99, 0.999])
array([2.05746321e-09, 1.97259354e-17, 1.96467954e-25])