dpois_mix: Poisson Mixture Density

Description Usage Arguments Details Examples

View source: R/dpois_mix.R

Description

Gives the density value of a univariate Poisson mixture.

Usage

1
dpois_mix(x, pi, lambda)

Arguments

x

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

pi

vector of mixture weights.

lambda

vector os parameters(means).

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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(seq(0, 10000, by = 1)))

matheuscastro43/mixGM documentation built on March 2, 2020, 12:19 a.m.