# 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? –  Tom Tucker Sep 29 '13 at 0:23
Well, this is a linear combination of random variables so you can try looking that term up. As is often the case in mathematics, the proof of something can be much more complicated than the result. I saw a proof using generating functions, so if you know much about those then that could be useful. Intuitively speaking we are stretching the distribution by a factor of sigma to increase the variance, then adding the mean. –  Fred Reckless Sep 29 '13 at 0:33

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...

-