gompertzUC.RdDensity, cumulative distribution function, quantile function and random generation for the Gompertz distribution.
dgompertz(x, scale = 1, shape, log = FALSE)
pgompertz(q, scale = 1, shape, lower.tail = TRUE, log.p = FALSE)
qgompertz(p, scale = 1, shape, lower.tail = TRUE, log.p = FALSE)
rgompertz(n, scale = 1, shape)dgompertz gives the density,
pgompertz gives the cumulative distribution function,
qgompertz gives the quantile function, and
rgompertz generates random deviates.
See gompertz for details.
probs <- seq(0.01, 0.99, by = 0.01)
Shape <- exp(1); Scale <- exp(1)
max(abs(pgompertz(qgompertz(p = probs, Scale, shape = Shape),
Scale, shape = Shape) - probs)) # Should be 0
#> [1] 1.665335e-16
if (FALSE) x <- seq(-0.1, 1.0, by = 0.001)
plot(x, dgompertz(x, Scale,shape = Shape), type = "l", las = 1,
main = "Blue is density, orange is the CDF", col = "blue",
sub = "Purple lines are the 10,20,...,90 percentiles",
ylab = "")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'x' not found
abline(h = 0, col = "blue", lty = 2)
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet
lines(x, pgompertz(x, Scale, shape = Shape), col = "orange")
#> Error: object 'x' not found
probs <- seq(0.1, 0.9, by = 0.1)
Q <- qgompertz(probs, Scale, shape = Shape)
lines(Q, dgompertz(Q, Scale, shape = Shape), col = "purple",
lty = 3, type = "h")
#> Error in plot.xy(xy.coords(x, y), type = type, ...): plot.new has not been called yet
pgompertz(Q, Scale, shape = Shape) - probs # Should be all zero
#> [1] 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
#> [6] 0.000000e+00 1.110223e-16 -1.110223e-16 0.000000e+00
abline(h = probs, col = "purple", lty = 3) # \dontrun{}
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet