Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

Thanks in advance!

share|cite|improve this question
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
up vote 4 down vote accepted

Assume we are talking about a standard normal distribution with zero mean and unit variance. For the observer to be able to answer the question "is this sample from a standard normal distribution?" with a high probability of correctness, he needs to know the distribution of distributions from which the sample may have been generated. The probability that the observer will guess "yes" is maximized when the sample is generated from a standard normal distribution, assuming that is possible. So according to my interpretation, you should use the values generated by Box-Muller in step 1 without inspecting them.

share|cite|improve this answer
Repeating comment from above: I should say that this is for a perception experiment. If you sample 10 values from a normal distribution and get all 0s, it is technically a random set (albeit unlikely). However, someone looking at it would say that it appears to have low variance. See figure 1 here – sharoz Oct 11 '11 at 6:41
I skimmed the paper and I think my answer still applies. If you are trying to determine the perceptual threshold for normally-distributed orientation variance, then you should stop at step 1. Otherwise you are using a distribution that is not normal. Also, you should generate a new random image for each perception experiment to maximize the SNR. – Dan Brumleve Oct 11 '11 at 6:48
Very well. One step it is. Thanks for the help and info! – sharoz Oct 11 '11 at 6:52
You are welcome sir. – Dan Brumleve Oct 11 '11 at 6:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.