library(ggplot2)
mm <- dist_mixture(list(
dist_exponential(NULL),
dist_lognormal(0.5, NULL)
), list(NULL, 1))
ph <- mm$get_placeholders()
ph_flat <- flatten_params(ph)
ph_reinflated <- inflate_params(ph_flat)
ph_flat[] <- c(1, 1, 6)
ph_sample <- inflate_params(ph_flat)
x <- mm$sample(
100,
with_params = ph_sample
)
emp_cdf <- ecdf(x)
ggplot(data.frame(t = seq(from = min(x), to = max(x), length.out = 100))) %+%
geom_point(aes(x = t, y = emp_cdf(t))) %+%
geom_line(aes(x = t, y = mm$probability(t, with_params = ph_sample)),
linetype = 2)
Run the code above in your browser using DataLab