probs <- seq(0.01, 0.99, by = 0.01)
Shape <- exp(1); Scale <- exp(1);
max(abs(pgompertz(qgompertz(p = probs, Shape, Scale),
Shape, Scale) - probs)) # Should be 0
x <- seq(-0.1, 1.0, by = 0.01);
plot(x, dgompertz(x, Shape, Scale), type = "l", col = "blue", las = 1,
main = "Blue is density, orange is cumulative distribution function",
sub = "Purple lines are the 10,20,...,90 percentiles",
ylab = "")
abline(h = 0, col = "blue", lty = 2)
lines(x, pgompertz(x, Shape, Scale), col = "orange")
probs <- seq(0.1, 0.9, by = 0.1)
Q <- qgompertz(probs, Shape, Scale)
lines(Q, dgompertz(Q, Shape, Scale), col = "purple", lty = 3, type = "h")
pgompertz(Q, Shape, Scale) - probs # Should be all zero
abline(h = probs, col = "purple", lty = 3)
Run the code above in your browser using DataLab