Description Usage Arguments Details Examples
Gives the density value of a univariate Poisson mixture.
1 |
x |
value or vector of values, to apply in the mixture probability density function. |
pi |
vector of mixture weights. |
lambda |
vector os parameters(means). |
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.
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)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.