# Creating somewhat-normal distributions using random numbers - Why does this work?

I'm a software engineer. I asked a friend for help easily creating a somewhat-normal distribution. This is just for the purpose of adding entropy to an application.

The code he gave me is this:

(rand(-1000, 1000) + rand(-1000, 1000) + rand(-1000, 1000)) / 100

If I run this 1000 times, it produces results between -27 and 28, with a good-enough normal distribution:

Mean: -0.671 Median: -1 Std Dev: 9.9

I'm not as good at math as I should be. Can anybody help me understand why this works?

-
First of all the binomial distribution has parameters p and n and takes values on the integers from 0 to n. So what you get from a scaled value of the sum of three independent uniforms is not binomial. It will be roughly normal by the CLT as Xoff points out. But I don't see how explaining that something is approximately normal answers the question "Why does this look somewhat binomial?" It doesn't look binomial at all! –  Michael Chernick Aug 7 '12 at 20:37
Ok, I would be just as critical if you misused software engineering terms. So appreciate the correction. ---- So why does this look "somewhat normal" ? –  Encoderer Aug 7 '12 at 20:41
The central limit theorem says that averages of random variables that are independent and identically distributed (with certain conditions on existence of moments) will approach the normal distribution as n gets large. In this case n is only 3 but the approximation is starting to work. –  Michael Chernick Aug 7 '12 at 20:51
A "poor man's normal random variable generator" sums $12$ random variables uniformly distributed on $(0,1)$, e.g. the results of $12$ calls to rand() in many computer languages, and subtracts $6$. This gives a number in $(-6,6)$ that can be taken as a sample of a $\mathcal N(0,1)$ random variable. The choice of $12$ samples allows elimination of a division to get the scaling correct: variance to be $1$. Of course, the Box-Muller transform gives better results..... –  Dilip Sarwate Aug 7 '12 at 21:55