Generate random numbers with fixed mean and sd
问题 When generating random numbers in R using rnorm (or runif etc.), they seldom have the exact mean and SD as the distribution they are sampled from. Is there any simple one-or-two-liner that does this for me? As a preliminary solution, I've created this function but it seems like something that should be native to R or some package. # Draw sample from normal distribution with guaranteed fixed mean and sd rnorm_fixed = function(n, mu=0, sigma=1) { x = rnorm(n) # from standard normal distribution