Skip to main content
`Ctrl`+`K`

# 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, b array_like

      Positive, real-valued parameters

    x array_like

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

    out ndarray, optional

      Optional output array for the function values

  Returns:
    scalar or ndarray

      Value 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 experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable `SCIPY_ARRAY_API=1` and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. 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

  > 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])