scipy.special.bdtrc#
- scipy.special.bdtrc(k, n, p, out=None) = <ufunc 'bdtrc'>#
Binomial distribution survival function.
Sum of the terms floor(k) + 1 through n of the binomial probability density,
\[\mathrm{bdtrc}(k, n, p) = \sum_{j=\lfloor k \rfloor +1}^n {{n}\choose{j}} p^j (1-p)^{n-j}\]- Parameters:
- karray_like
Number of successes (double), rounded down to nearest integer.
- narray_like
Number of events (int)
- parray_like
Probability of success in a single event.
- outndarray, optional
Optional output array for the function values
- Returns:
- yscalar or ndarray
Probability of floor(k) + 1 or more successes in n independent events with success probabilities of p.
Notes
The terms are not summed directly; instead the regularized incomplete beta function is employed, according to the formula,
\[\mathrm{bdtrc}(k, n, p) = I_{p}(\lfloor k \rfloor + 1, n - \lfloor k \rfloor).\]Wrapper for the Cephes [1] routine
bdtrc.Array API Standard Support
bdtrchas experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variableSCIPY_ARRAY_API=1and 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]Cephes Mathematical Functions Library, https://netlib.org/cephes/
Examples
We have a coin for which the probability of showing heads when flipped is 0.525. The coin is flipped 16 times. What is the probability that the number of heads is greater than 10?
Let X be the number of heads. We want to find the probability that X > k, given k is 10, the total number of flips n is 16 and the probability p of heads in a single flip is 0.525. This is what
bdtrc(k, n, p)computes:>>> from scipy.special import bdtrc
>>> bdtrc(10, 16, 0.525) np.float64(0.14643065267555583)
The following plot shows the graph
bdtrc(k, 16, 0.525):>>> import numpy as np >>> import matplotlib.pyplot as plt
>>> n = 16 >>> p = 0.525 >>> k = np.arange(n + 1) >>> plt.plot(k, bdtrc(k, n, p), 'o') >>> plt.grid(True) >>> plt.xlabel('k') >>> plt.title(f"bdtrc(k, {n}, {p})") >>> plt.show()