dpois_mix: Poisson Mixture Probability Mass

View source: R/dpois_mix.R

Probability Mass Poisson MixtureR Documentation

Poisson Mixture Probability Mass

Description

Gives the probability mass value of a univariate Poisson Mixture.

Usage

dpois_mix(x, pi, lambda, log = FALSE)

Arguments

x

value or vector of values, to apply in the mixture probability mass function.

pi

vector of mixture weights.

lambda

vector os parameters (means).

log

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

Details

Each component of the mixture has density

f_j(x) = (exp(- λ_j) * λ_j^(x))) / (x!)

where λ_j is the mean and the variance of the jth component. j = 1, 2, ..., g.

Author(s)

CASTRO, M. O.; MONTALVO, G. S. A.

Examples

f <- function(x){dpois_mix(x, c(0.5, 0.5), c(3, 8))}
## Plot using graphics package
require(graphics)
plot.function(f, 0, 10, type = "h")

require(ggplot2)
## Plot using ggplot2 package
x <- seq(0, 20, 1)
aux <- data.frame(x, y = f(x))

ggplot(aux, aes(x=x)) +
  geom_point( aes(y=y) ) +
  geom_linerange(aes(ymax=y), ymin=0) +
  theme_minimal()

## Sum
sum(f(0:10000))

matheuscastro43/finiteMix documentation built on March 30, 2022, 12:49 p.m.