alpha <- 2
beta <- 2
d_gamma <- dist_gamma(shape = alpha, rate = beta)
x <- d_gamma$sample(100)
d_emp <- dist_empirical(x, positive = TRUE)
plot_distributions(
empirical = d_emp,
theoretical = d_gamma,
estimated = d_gamma,
with_params = list(
estimated = inflate_params(
fitdistrplus::fitdist(x, distr = "gamma")$estimate
)
),
.x = seq(1e-3, max(x), length.out = 100)
)
Run the code above in your browser using DataLab