# Draw random samples from a mixture of two equally likely normal
# distributions, one with mean = -2, s.d. = 1, and the other with
# mean=2, s.d. = 4
x <- rnormmix(200, c(0.5, 0.5), c(-2, 2), c(1, 4))
hist(x, probability=TRUE)
lines(density(x), col='red')
Run the code above in your browser using DataLab