Skip to contents

Generates samples from a Skellam distribution (difference of two Poissons) with the given predictions as means and the estimated variance. This is the sampling counterpart to fit_skellam().

The Skellam distribution is parameterized by λ₁ and λ₂ where:

  • Mean = λ₁ - λ₂ = pred

  • Variance = λ₁ + λ₂ = uncertainty_params

The individual parameters are recovered as:

  • λ₁ = (pred + variance) / 2

  • λ₂ = (variance - pred) / 2

Usage

sample_skellam(pred, uncertainty_params)

Arguments

pred

Vector of predictions (means). Can be negative.

uncertainty_params

Vector of variance parameters. Must satisfy variance > |pred| for valid Poisson parameters. If length 1, the same variance is used for all predictions.

Value

Integer vector of samples of the same length as pred.

See also

Other sample_distribution: sample_normal()

Examples

pred <- c(3.2, -1.5, 0.8)
variance <- 10
samples <- sample_skellam(pred, uncertainty_params = variance)
samples
#> [1]  1 -6  4