Package 'ShiftConvolvePoibin'

Title: Exactly Computing the Tail of the Poisson-Binomial Distribution
Description: An exact method for computing the Poisson-Binomial Distribution (PBD). The package provides a function for generating a random sample from the PBD, as well as two distinct approaches for computing the density, distribution, and quantile functions of the PBD. The first method uses direct-convolution, or a dynamic-programming approach which is numerically stable but can be slow for a large input due to its quadratic complexity. The second method is much faster on large inputs thanks to its use of Fast Fourier Transform (FFT) based convolutions. Notably in this case the package uses an exponential shift to practically guarantee the relative accuracy of the computation of an arbitrarily small tail of the PBD -- something that FFT-based methods often struggle with. This ShiftConvolvePoiBin method is described in Peres, Lee and Keich (2020) <arXiv:2004.07429> where it is also shown to be competitive with the fastest implementations for exactly computing the entire Poisson-Binomial distribution.
Authors: Andrew Lee [aut, cre], Noah Peres [aut, ctb], Uri Keich [aut, ctb], Alexander Mukhin [cph]
Maintainer: Andrew Lee <[email protected]>
License: GPL (>= 2)
Version: 1.0.0
Built: 2024-12-19 06:52:28 UTC
Source: CRAN

Help Index


ShiftConvolve Poisson Binomial

Description

Density, distribution function, quantile function and random generation for the Poisson binomial distribution with the option of using the ShiftConvolvePoibin method.

Usage

dpoisbin(x, probs, method = "ShiftConvolve", log.p = FALSE)

ppoisbin(x, probs, method = "ShiftConvolve", lower.tail = TRUE, log.p = FALSE)

qpoisbin(p, probs, method = "ShiftConvolve", lower.tail = TRUE, log.p = FALSE)

rpoisbin(n, probs)

Arguments

x

Either a vector of observed numbers of successes (or vector of quantiles as dbinom/pbinom refers to) or NULL. If NULL, probabilities of all possible observations are returned.

probs

Vector of probabilities of success of each Bernoulli trial.

method

Character string that specifies the method of computation and must be either "ShiftConvolve" or "DC"

log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

Logical value indicating if results are P[Xx]P[X \le x] (if TRUE; default) or P[X>x]P[X > x] (if FALSE).

p

Vector of probabilities for computation of quantiles.

n

Number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Computing the Poisson Binomial Distribution using ShiftConvolve

A package which uses exponential shifting and Fast Fourier Transformations with the minFFT library to compute the distribution of the Poisson Binomial Distribution

Value

dpoisbin gives the density, ppoisbin computes the distribution function, qpoisbin gives the quantile function and rpoisbin generates random deviates.

References

Peres, N., Lee, A., and Keich, U. (2020). Exactly computing the tail of the Poisson-Binomial Distribution. arXiv:2004.07429

Author(s)

Andrew Ray Lee, Noah Peres and Uri Keich

Examples

set.seed(18)
n=1000
probs <- runif(n)
x <- c(200, 500, 800)
p <- seq(0, 1, 0.01)
dpoisbin(x,probs,method="ShiftConvolve",log.p=FALSE)
ppoisbin(x,probs,method="ShiftConvolve",lower.tail=FALSE,log.p=TRUE)
qpoisbin(p,probs,method="ShiftConvolve",lower.tail=TRUE,log.p=FALSE)
rpoisbin(n,probs)