scipy.special.poisson_binom_cdf#
- scipy.special.poisson_binom_cdf = <wrapped_ufunc 'poisson_binom_cdf'>#
Poisson binomial cumulative distribution function.
The Poisson binomial distribution is the discrete probability distribution of a sum of independent Bernoulli trials that are not necessarily identically distributed [1].
- Parameters:
- karray_like of int
Number of successes at which to evaluate the CDF.
- parray_like of float
Success probabilities of independent Bernoulli trials.
- outndarray, optional
Optional output array for the function results.
- **kwargs
For other keyword-only arguments, see the NumPy ufunc docs.
- Returns:
- scalar or ndarray
Values of the Poisson binomial cumulative distribution function.
See also
Notes
For \(\mathbf{p} = \left(p_1, p_2, \ldots, p_n\right)\) giving the success probabilities for a sequence of \(n\) independent Bernoulli trials
\[\mathrm{CDF}(k, \mathbf{p}) = \sum_{l=0}^{k}\sum_{A \in F_l}\prod_{i \in A} p_i \prod_{j \in A^c} (1 - p_j)\]where \(F_l\) is the set of all subsets of size \(l\) of \(\{1, 2, \ldots, n\}\) and \(A^c\) is the complement of \(A\) in \(\{1, 2, \ldots, n\}\).
Added in version 2.0.0.
Array API Standard Support
poisson_binom_cdfhas 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.outis 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.outis never supported for JAX because JAX arrays are immutable.poisson_binom_cdfdoes not currently supportoutfor the PyTorch backend. It supports theaxiskwarg for all supported backends.See Support for the array API standard for more information.
References
Examples
>>> import numpy as np >>> from scipy.special import poisson_binom_cdf
A batch of two Poisson binomial distributions involving three trials each.
>>> p = np.asarray([[0.2, 0.4, 0.6], [0.3, 0.3, 0.1]])
Evaluate the cdf across the entire support. An extra dimension is added to
kto broadcast against the batch dimension ofp.>>> k = np.asarray([0, 1, 2, 3])[:, None] >>> poisson_binom_cdf(k, p) array([[0.192, 0.441], [0.656, 0.868], [0.952, 0.991], [1. , 1. ]])