lambda = 3; phi = 0.2; x = (-1):7
(ii = dzipois(x, lambda, phi))
max(abs(cumsum(ii) - pzipois(x, lambda, phi))) # Should be 0
table(rzipois(100, lambda, phi))
table(qzipois(runif(100), lambda, phi))
round(dzipois(0:10, lambda, phi) * 100) # Should be similar
x = 0:10
barplot(rbind(dzipois(x, lambda, phi), dpois(x, lambda)),
beside = TRUE, col = c("blue","orange"),
main = paste("ZIP(", lambda, ", phi = ", phi, ") (blue) vs",
" Poisson(", lambda, ") (orange)", sep = ""),
names.arg = as.character(x))
Run the code above in your browser using DataLab