set.seed(19843) # generate existing pool from which we want the sample pool = rnorm(10000, mean=100, sd=15) pool = sort(pool) # get probability density distribution under original # sample and under desired mean and sd target_mean = 80; target_sd = 15 dens1 = dnorm(pool, mean=mean(pool), sd=sd(pool)) dens2 = dnorm(pool, mean=target_mean, sd=target_sd) # get desired sampling probability prob = dens2/dens1 prob = prob/sum(prob) # sample from the pool with replacement where each # value is sampled with the corresponding probability mysample = sample(pool, 10000, replace=T, prob=prob) # confirm that sample has desired parameters options(repr.plot.width=3, repr.plot.height=3) hist(mysample) mean(mysample) sd(mysample)