A: 

This is just a mixture of normals. So why not something like:

rmnorm <- function(n,mean, sd,prob) {
    nmix <- length(mean)
    if (length(sd)!=nmix) stop("lengths should be the same.")
    y <- sample(1:nmix,n,prob=prob, replace=TRUE)
    mean.mix <- mean[y]
    sd.mix <- sd[y]
    rnorm(n,mean.mix,sd.mix)
}
plot(density(rmnorm(10000,mean=c(0,3), sd=c(1,2), prob=c(.5,.5))))

This should be fine if all you need are samples from this mixture distribution.

Eduardo Leoni
I like the idea! But my example is oversimplified for illustrative purposes. In reality I don't know the two modes and it might have just one mode and a long ass tail (i.e. leptokurtosis). But I like your example. I could not have programmed that near as succinctly. BTW, i believe are missing a c in :plot(density(rmnorm(10000,mean=c(0,3), sd=c(1,2), prob=c(.5,.5))))
JD Long
@JD Long: thanks for spotting the typo.
Eduardo Leoni
Which is why you want Hadley's answer -- resampling it is. Remember that your density plot is /just an estimate/ that also depends on your smoothing parameter.
Dirk Eddelbuettel
+3  A: 

Alternative approach:

sample(x, n, replace = TRUE)
hadley
bootstrapping ftw!
Eduardo Leoni
yeah, I've been over thinking this. If I do sample + a draw from a normal I should end up thickening my tails the same way the kernel would, right? Assuming I param my normal the same way the kerneling method would.
JD Long
Yes, add normal rvs with zero mean and sd=bandwidth from density estimate: sample(x, n, replace=TRUE) + rnorm(n,0,sd=0.4214)Simulating like this is discussed in Silverman's 1986 book on density estimation.
Rob Hyndman