next up previous index
Next: Generating Random Variables From Up: Generating Random Variables Previous: Sampling From a Distribution   Index

Click for printer friendely version of this HowTo

Generating Normally Distributed Random Variables

There are two primary methods for generating normally distributed random variables. The first method relies on the central limit theorem which states that if E$ X = \mu$ and Var $ (X) = \sigma^2$, then for independent and identically distributed samples from any distribution $ \bar{X}$ has an approximate $ \textrm{N}(\mu, \sigma^2/n)$ distribution, where $ n$ is the sample size. The utility in this first method is that it is very easy to remember off the top of your head and is relatively easy to compute with a computer.

The second method uses a direct transformation, and, while being just as easy to compute using a computer, is a little tricky to remember. This method is called the Box-Muller algorithm. The steps involved are:

  1. Generate to independent uniform(0,1) variables, $ U_1$, $ U_2$.
  2. Let $ R = \sqrt{-2 \log(U_1)}$ and $ \theta = 2 \pi U_2$
  3. Let $ X = R \cos(\theta)$ and $ Y = R \sin(\theta)$.
where $ X$ and $ Y$ are independent normal(0,1) random variables. See Appendix A.2 for an Octave program that implements this algorithm.


next up previous index
Next: Generating Random Variables From Up: Generating Random Variables Previous: Sampling From a Distribution   Index

Click for printer friendely version of this HowTo

Frank Starmer 2004-05-19
>