diff --git a/src/functions-reference/bounded_discrete_distributions.qmd b/src/functions-reference/bounded_discrete_distributions.qmd index 209671602..862f5daf1 100644 --- a/src/functions-reference/bounded_discrete_distributions.qmd +++ b/src/functions-reference/bounded_discrete_distributions.qmd @@ -353,6 +353,99 @@ For a description of argument and return types, see section [vectorized PRNG functions](conventions_for_probability_functions.qmd#prng-vectorization). {{< since 2.18 >}} +## Poisson-binomial distribution {#poisson-binomial} + +Also known as the "generalized Binomial distribution", the Poission-binomial +distribution models the distribution of successes in a set of trials with +different probabilities for each trial. + +### Probability mass function + +Suppose $N \in \mathbb{N}$, $n \in \{0,\ldots,N\}$, and $\theta \in [0,1]^N$. Let +$Sub_n$ denote the set of all size-$n$ subsets of $\{0,\ldots,N\}$^[In practice, +the calculation of this density can be done much quicker than the $\binom{N}{n}$ +the formula suggests.]. +Then, \begin{equation*} \text{PoissonBinomial}(y~|~\theta) = \sum_{A\in Sub_n} \prod_{i\in A} \theta_i \prod_{j\in A^c} (1-\theta_j). \end{equation*} + + + +### Distribution statement + + +`n ~ ` **`poisson_binomial`**`(theta)` + +Increment target log probability density with `poisson_binomial_lupmf(n | theta)`. +{{< since 2.40 >}} + +\index{{\tt \bfseries poisson\_binomial }!distribution statement|hyperpage} + +### Stan functions + + +\index{{\tt \bfseries poisson\_binomial\_lpmf }!{\tt (ints n \textbar vectors theta): real}|hyperpage} + +`real` **`poisson_binomial_lpmf`**`(ints n | vectors theta)`
\newline + +The log poisson-binomial probability mass of `n` successes in +`N = size(theta)` independent trials with probabilities of success `theta[1]`, ..., +`theta[N]` +{{< since 2.40 >}} + + + +\index{{\tt \bfseries poisson\_binomial\_lupmf }!{\tt (ints n \textbar vectors theta): real}|hyperpage} + +`real` **`poisson_binomial_lupmf`**`(ints n | vectors theta)`
\newline + +The log poisson-binomial probability mass of `n` successes in +`N = size(theta)` independent trials with probabilities of success `theta[1]`, ..., +`theta[N]` dropping constant additive terms +{{< since 2.40 >}} + + + +\index{{\tt \bfseries poisson\_binomial\_cdf }!{\tt (ints n \textbar vectors theta): real}|hyperpage} + +`real` **`poisson_binomial_cdf`**`(ints n | vectors theta)`
\newline + +The poisson-binomial cumulative distribution function of `n` successes in +`N = size(theta)` independent trials with probabilities of success `theta[1]`, ..., +`theta[N]` +{{< since 2.40 >}} + + + +\index{{\tt \bfseries poisson\_binomial\_lcdf }!{\tt (ints n \textbar vectors theta): real}|hyperpage} + +`real` **`poisson_binomial_lcdf`**`(ints n | vectors theta)`
\newline + +The log of the poisson-binomial cumulative distribution function of `n` successes in +`N = size(theta)` independent trials with probabilities of success `theta[1]`, ..., +`theta[N]` +{{< since 2.40 >}} + + + +\index{{\tt \bfseries poisson\_binomial\_lccdf }!{\tt (ints n \textbar vectors theta): real}|hyperpage} + +`real` **`poisson_binomial_lccdf`**`(ints n | vectors theta)`
\newline + +The log of the poisson-binomial complementary cumulative distribution function +of `n` successes in `N = size(theta)` independent trials with probabilities of +success `theta[1]`, ..., `theta[N]` +{{< since 2.40 >}} + + + +\index{{\tt \bfseries poisson\_binomial\_rng }!{\tt (vectors theta): int}|hyperpage} + +`int` **`poisson_binomial_rng`**`(vectors theta)`
\newline + +Generate a poisson-binomial variant of `N = size(theta)` independent trials with +probabilities of success `theta[1]`, ..., `theta[N]`; may only be used in +transformed data and generated quantities blocks. +{{< since 2.40 >}} + ## Hypergeometric distribution ### Probability mass function diff --git a/src/functions-reference/functions_index.qmd b/src/functions-reference/functions_index.qmd index 952ebe1e7..d1c8c2c97 100644 --- a/src/functions-reference/functions_index.qmd +++ b/src/functions-reference/functions_index.qmd @@ -3289,6 +3289,41 @@ pagetitle: Alphabetical Index -
[distribution statement](unbounded_discrete_distributions.qmd#index-entry-149c7a2f2ae0aede0ae6b19854be4a72ba136d10) (unbounded_discrete_distributions.html)
+**poisson_binomial**: + + -
[distribution statement](bounded_discrete_distributions.qmd#index-entry-dbff3b80596957f04c6b36c11f676843500a2197) (bounded_discrete_distributions.html)
+ + +**poisson_binomial_cdf**: + + -
[`(ints n | vectors theta) : real`](bounded_discrete_distributions.qmd#index-entry-e66030c1892345418de30c136c86a2da5b8ac9a5) (bounded_discrete_distributions.html)
+ + +**poisson_binomial_lccdf**: + + -
[`(ints n | vectors theta) : real`](bounded_discrete_distributions.qmd#index-entry-a59f57b0982b1a3044bf546046af18d15789e43d) (bounded_discrete_distributions.html)
+ + +**poisson_binomial_lcdf**: + + -
[`(ints n | vectors theta) : real`](bounded_discrete_distributions.qmd#index-entry-8569a8fe8196ab50641a92b8210303262a07971b) (bounded_discrete_distributions.html)
+ + +**poisson_binomial_lpmf**: + + -
[`(ints n | vectors theta) : real`](bounded_discrete_distributions.qmd#index-entry-3057454ff3ac5b4c322ec8929fdd63b132235e75) (bounded_discrete_distributions.html)
+ + +**poisson_binomial_lupmf**: + + -
[`(ints n | vectors theta) : real`](bounded_discrete_distributions.qmd#index-entry-971c6a169fb16a00281fd6392974034022d228dc) (bounded_discrete_distributions.html)
+ + +**poisson_binomial_rng**: + + -
[`(vectors theta) : int`](bounded_discrete_distributions.qmd#index-entry-1c84520e678c328dd081b4c4362b854b86cee004) (bounded_discrete_distributions.html)
+ + **poisson_cdf**: -
[`(ints n | reals lambda) : real`](unbounded_discrete_distributions.qmd#index-entry-b9228882bc1807740bfbe2278fe3865895ddc14f) (unbounded_discrete_distributions.html)