# Generate a set of random numbers with a normal distribution

I am trying to generate a set of N random numbers where the set has a normal distribution.

I'm currently using a brute force approach:

1. Randomly select N numbers from a normal distribution.
2. Check the set's standard deviation (more important than mean).
3. If it is the best set so far, keep it.
4. Repeat 10000 times, and use the best set.

Is there any better approach? Anyone know where I could look?

-
If you stop after step 1, then you already have a sample from a normal distribution. I don't think it makes any sense to say that any particular set has a normal distribution. I guess you are trying to maximize the likelihood that this particular sample came from a normal distribution, given some meta-distribution of possible distributions? – Dan Brumleve Oct 11 '11 at 4:36
Look at this article for ideas. The usual pseudo-random number generators give you, more or less, random variables uniformly distributed on $[0,1]$. Given such a generator, you can fiddle with it to get a standard normal. The Box-Muller method is good, not hard to implement. To simulate a normal with mean $\mu$, standard deviation $\sigma$, multiply by $\sigma$, add $\mu$. Repeat $5000$ times to get your simulated sample. – André Nicolas Oct 11 '11 at 4:48
André: That's currently what I'm doing. I was just curious if there was a way to avoid the "repeat 5000 times" step. – sharoz Oct 11 '11 at 4:58
@sharoz, I don't think it makes sense. Using Box-Muller in step 1, you have a sample from a normal distribution. Rejecting and iterating gives you a sample from some other distribution no matter what criteria are used. What good is it for it to appear normal if it is actually not? (Although now I am curious exactly what distribution does this procedure produce?) – Dan Brumleve Oct 11 '11 at 5:36
If you sample 10 values... and get all 0s, the normality is dubious. // Since we are considering sample variances, I might refer you to this, if only to stress that the empirical variance of a sample is itself random, and liable, in principle, to take any positive value whatsoever. – Did Oct 11 '11 at 6:50