PoissonBinomial: Create a Poisson binomial distribution

View source: R/PoissonBinomial.R

PoissonBinomialR Documentation

Create a Poisson binomial distribution

Description

The Poisson binomial distribution is a generalization of the Binomial distribution. It is also a sum of n independent Bernoulli experiments. However, the success probabilities can vary between the experiments so that they are not identically distributed.

Usage

PoissonBinomial(...)

Arguments

...

An arbitrary number of numeric vectors or matrices of success probabilities in ⁠[0, 1]⁠ (with matching number of rows).

Details

The Poisson binomial distribution comes up when you consider the number of successes in independent binomial experiments (coin flips) with potentially varying success probabilities.

The PoissonBinomial distribution class in distributions3 is mostly based on the PoissonBinomial package, providing fast Rcpp implementations of efficient algorithms. Hence, it is recommended to install the PoissonBinomial package when working with this distribution. However, as a fallback for when the PoissonBinomial package is not installed the methods for the PoissonBinomial distribution employ a normal approximation.

We recommend reading the following documentation on https://alexpghayes.github.io/distributions3/, where the math will render with additional detail.

In the following, let X be a Poisson binomial random variable with success probabilities p_1 to p_n.

Support: \{0, 1, 2, ..., n\}

Mean: p_1 + \dots + p_n

Variance: p_1 \cdot (1 - p_1) + \dots + p_1 \cdot (1 - p_1)

Probability mass function (p.m.f):

P(X = k) = \sum_A \prod_{i \in A} p_i \prod_{j \in A^C} (1 - p_j)

where the sum is taken over all sets A with k elements from \{0, 1, 2, ..., n\}. A^C is the complement of A.

Cumulative distribution function (c.d.f):

P(X \le k) = \sum_{i=0}^{\lfloor k \rfloor} P(X = i)

Moment generating function (m.g.f):

E(e^{tX}) = \prod_{i = 1}^n (1 - p_i + p_i e^t)

Value

A PoissonBinomial object.

See Also

Other discrete distributions: Bernoulli(), Binomial(), Categorical(), Geometric(), HurdleNegativeBinomial(), HurdlePoisson(), HyperGeometric(), Multinomial(), NegativeBinomial(), Poisson(), ZINegativeBinomial(), ZIPoisson(), ZTNegativeBinomial(), ZTPoisson()

Examples


set.seed(27)

X <- PoissonBinomial(0.5, 0.3, 0.8)
X

mean(X)
variance(X)
skewness(X)
kurtosis(X)

random(X, 10)

pdf(X, 2)
log_pdf(X, 2)

cdf(X, 2)
quantile(X, 0.8)

cdf(X, quantile(X, 0.8))
quantile(X, cdf(X, 2))

## equivalent definitions of four Poisson binomial distributions
## each summing up three Bernoulli probabilities
p <- cbind(
  p1 = c(0.1, 0.2, 0.1, 0.2),
  p2 = c(0.5, 0.5, 0.5, 0.5),
  p3 = c(0.8, 0.7, 0.9, 0.8))
PoissonBinomial(p)
PoissonBinomial(p[, 1], p[, 2], p[, 3])
PoissonBinomial(p[, 1:2], p[, 3])

alexpghayes/distributions documentation built on May 18, 2024, 3:44 p.m.