PoissonMix function

Mixture of Poisson distributions

Mixture of Poisson distributions

Density, distribution function and random generation for the mixture of Poisson distributions.

dmixpois(x, lambda, alpha, log = FALSE) pmixpois(q, lambda, alpha, lower.tail = TRUE, log.p = FALSE) rmixpois(n, lambda, alpha)

Arguments

  • x, q: vector of quantiles.

  • lambda: matrix (or vector) of (non-negative) means.

  • alpha: matrix (or vector) of mixing proportions; mixing proportions need to sum up to 1.

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

  • lower.tail: logical; if TRUE (default), probabilities are P[Xx]P[X \le x]

    otherwise, P[X>x]P[X > x].

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

  • p: vector of probabilities.

Details

Probability density function

f(x)=α1f1(x;λ1)++αkfk(x;λk)f(x)=α[1]f1(x;λ[1])++α[k]fk(x;λ[k]) f(x) = \alpha_1 f_1(x; \lambda_1) + \dots + \alpha_k f_k(x; \lambda_k)f(x) = \alpha[1] * f1(x; \lambda[1]) + \dots + \alpha[k] * fk(x; \lambda[k])

Cumulative distribution function

F(x)=α1F1(x;λ1)++αkFk(x;λk)F(x)=α[1]F1(x;λ[1])++α[k]Fk(x;λ[k]) F(x) = \alpha_1 F_1(x; \lambda_1) + \dots + \alpha_k F_k(x; \lambda_k)F(x) = \alpha[1] * F1(x; \lambda[1]) + \dots + \alpha[k] * Fk(x; \lambda[k])

where sum(α[i])==1sum(\alpha[i]) == 1.

Examples

x <- rmixpois(1e5, c(5, 12, 19), c(1/3, 1/3, 1/3)) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red") hist(pmixpois(x, c(5, 12, 19), c(1/3, 1/3, 1/3))) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, pmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red", lwd = 2)
  • Maintainer: Tymoteusz Wolodzko
  • License: GPL-2
  • Last published: 2023-11-30