Standard Normal Distribution to Normal Distribution

Given function f() which returns a random value from a standard normal distribution, is it possible to define a function g(mu, sigma) which returns a random value from a normal distribution with a mean of mu and a standard deviation of sigma?

This is a real-life question from work that I converted to a math queston.

Let $X\sim N(0,1)$ then $\sigma X+\mu\sim N(\mu,\sigma^2)$. In other words, multiply your observed value by sigma then add the mean.

• Thanks! I remember seeing this back in high school. Is there mathematical proof on the web that I can read for fun? Sep 29, 2013 at 0:23

In this particular case, the proof is very easy:

The pdf of a standard normal r.v. is

$$f_X(x) = \frac {1}{\sqrt {2\pi}} e^{-\frac 12 x^2}$$

We examine the random variable $Y = h(X) =\sigma X+\mu \Rightarrow X = h^{-1}(Y) = \frac {Y-\mu}{\sigma}$. Then by the change-of-variable formula we have that

$$f_Y(y)= \left|\frac {\partial X} {\partial Y}\right|f_X(h^{-1}(y))$$

We have $$\left|\frac {\partial X} {\partial Y}\right| = \frac {1}{\sigma}$$ Substituting we obtain

$$f_Y(y)= \frac {1}{\sigma}f_X\left(\frac {y-\mu}{\sigma}\right) = \frac {1}{\sigma\sqrt {2\pi}} e^{-\frac 12 \left(\frac {y-\mu}{\sigma}\right)^2}$$

...which is the density of a $N(\mu,\sigma^2)$ random variable. Now all you have to do is read about the proof of the change-of-variable formula...