Sample(Generate random variables) from normal distribution

In the following previous posts, I mentioned about rejection sampling.

nakaly.hatenablog.com

nakaly.hatenablog.com

But I was a little confused when I learn rejection sampling.

Because we need a known distribution which we already know how to draw samples from.

Of course I know how to sample from uniform distribution. (e.g. by using /dev/random in unix).

But I don’t know others…

I started googling about how to draw samples from normal distribution.

I found a post in stack exchange.

I don’t know how credible it is, but it seems to be decent.

There are two steps when we want to draw a sample from a normal distribution whose mean is  \mu and variance is  \sigma^{2}

  1. Draw a sample  x from a normal distribution with mean 0 and variance 1 .
  2. Transform the value  x to a sample from a normal distribution with mean  \mu and variance  \sigma^{2} by calculating  \sigma x \, + \, \mu.

Step 1 is not trivial. I think I will write about it next time.