This answer notes that if a programming language/libraries provide a procedure that returns random samples from a standard normal distribution, we can generate samples from another normal distribution with the same mean by multiplying the samples by the standard deviation $\sigma$ of the desired distribution.
This seems to work. For example, in R, these histograms produced by these two lines of code using the rnorm
function, which generates samples from a normal distribution, are visually indistinguishable:
hist(rnorm(100000, sd=0.5), xlim=c(-3,3), breaks=50)
hist(0.5*rnorm(100000), xlim=c(-3,3), breaks=50)
I don't understand why it works.
In both the normal probability density function and the cumulative distribution function, $\sigma$ appears, squared, in the argument of an exponential function.
Why should simply multiplying by standard deviation turns samples of the standard normal into samples of a distribution with that standard deviation? (It's not surprising that multiplying the standard normal PDF by a constant doesn't produce a PDF of the normal distribution with that standard deviation.)
(If the answer is closely related: For what classes of probability distributions does multiplying samples by a constant generate samples with a distribution whose standard deviation is that multiple of the original distribution's sd?)