library(mclust)
# Univariate mixture density
gmm <- Mclust(oldfaithful$duration) |> dist_mclust()
gg_density(gmm) +
geom_jitter(data = oldfaithful, aes(x=duration, y = -0.0002),
width=0, height=0.0002, alpha = 0.1) +
labs(x = "Eruption duration", y = "")
Run the code above in your browser using DataLab