x <- rmixnorm(1e5, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3))
xx <- seq(-20, 20, by = 0.1)
hist(x, 100, freq = FALSE)
lines(xx, dmixnorm(xx, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), col = "red")
hist(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)))
plot(ecdf(x))
lines(xx, pmixnorm(xx, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), col = "red", lwd = 2)
Run the code above in your browser using DataLab