shape <- 2; rate <- 2; nn <- 201
x <- seq(-0.05, 1.05, len = nn)
plot(x, dexppois(x, shape, rate = rate), type = "l", las = 1, ylim = c(0, 5),
ylab = paste("[dp]exppoisson(shape = ", shape, ", rate = ", rate, ")"),
col = "blue", cex.main = 0.8,
main = "Blue is density, orange is cumulative distribution function",
sub = "Purple lines are the 10,20,...,90 percentiles")
lines(x, pexppois(x, shape, rate = rate), col = "orange")
probs <- seq(0.1, 0.9, by = 0.1)
Q <- qexppois(probs, shape, rate = rate)
lines(Q, dexppois(Q, shape, rate = rate), col = "purple", lty = 3, type = "h")
lines(Q, pexppois(Q, shape, rate = rate), col = "purple", lty = 3, type = "h")
abline(h = probs, col = "purple", lty = 3)
max(abs(pexppois(Q, shape, rate = rate) - probs)) # Should be 0
Run the code above in your browser using DataLab