The normal distribution — step-by-step proofs with the Gaussian integral, the mgf and variances that add up (and the mean of −1010 grams)

The first time I computed the mean of the normal with the mgf, I found that the filling machine put in, on average, −1010 grams of gofio per packet. I had solved the standardisation the wrong way round: I wrote X=σZ−μX = \sigma Z – \mu instead of X=σZ+μX = \sigma Z + \mu, and that sign was dragged all the way to the end, where φX(t)=e−μt…\varphi_X(t) = e^{-\mu t}\ldots gave a negative mean. Since then, before using X=μ+σZX = \mu + \sigma Z I check that Z=0Z = 0 gives the mean, and it is the first check you will see here.

This article is the extension of the normal distribution theory: there you have the results and here, why they are true. They are the proofs asked for in the notes (theorems 5 and 6), the proposed exercises and the exam, with the same gofio filling machine, X∼N(1010,6)X \sim N(1010, 6). Each one goes step by step, with a single transformation per step and the rule that justifies it, and ends by checking the result with R.

Before you start: the rules we will use

All the proofs rely on these rules. We number them so we can cite them (“by rule 3”).

  1. Linearity of the integral and of expectation. ∫(a g+b h)=a∫g+b∫h\int (a\,g + b\,h) = a\int g + b\int h, and therefore E(aX+b)=a E(X)+bE(aX + b) = a\,E(X) + b and Var(aX+b)=a2 Var(X)\mathrm{Var}(aX + b) = a^2\,\mathrm{Var}(X).
  2. Linear change of variable. If u=x−csu = \frac{x – c}{s}, with s>0s > 0, then x=c+s ux = c + s\,u, dx=s dudx = s\,du, and the limits −∞-\infty and +∞+\infty stay −∞-\infty and +∞+\infty.
  3. Even and odd functions. If g(−x)=g(x)g(-x) = g(x) (even), ∫−∞∞g=2∫0∞g\int_{-\infty}^{\infty} g = 2\int_{0}^{\infty} g. If g(−x)=−g(x)g(-x) = -g(x) (odd) and the integral exists, ∫−∞∞g=0\int_{-\infty}^{\infty} g = 0.
  4. Completing the square. x2−2tx=(x−t)2−t2x^2 – 2tx = (x – t)^2 – t^2. Check it by expanding: (x−t)2−t2=x2−2tx+t2−t2(x – t)^2 – t^2 = x^2 – 2tx + t^2 – t^2.
  5. Fundamental theorem of calculus and chain rule. If FF is the distribution function of a continuous variable, F′(x)=f(x)F'(x) = f(x); and ddyF(g(y))=f(g(y)) g′(y)\frac{d}{dy} F(g(y)) = f(g(y))\,g'(y).
  6. Properties of the mgf. φX(t)=E(etX)\varphi_X(t) = E(e^{tX}); φaX+b(t)=ebt φX(at)\varphi_{aX+b}(t) = e^{bt}\,\varphi_X(at); if XX and YY are independent, φX+Y(t)=φX(t) φY(t)\varphi_{X+Y}(t) = \varphi_X(t)\,\varphi_Y(t); E(Xk)=φX(k)(0)E(X^k) = \varphi_X^{(k)}(0); and the mgf characterises the distribution: two variables with the same mgf (on a neighbourhood of 0) have the same distribution.

Rule 6 is the one from topics 3 and 4; the only real novelty is the last sentence, which is what turns the mgf into a tool for proving that something “is normal”.

Proof 1: the density integrates to 1 (the Gaussian integral)

What we want to prove

That the normal density is a density: it is positive (it is, because it is an exponential times a positive constant) and its total area is 1:

∫−∞∞1σ2π e−(x−μ)22σ2 dx=1 \int_{-\infty}^{\infty} \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{(x-\mu)^2}{2\sigma^2}}\, dx = 1

Why it matters. Without this calculation, the normal formula wouldn’t be a density: every probability you compute with pnorm rests on the total area being 1. Besides, the constant 1σ2π \frac{1}{\sigma\sqrt{2\pi}} stops being a strange number you memorise: it’s exactly what’s needed for the area to come out as 1. And the Gaussian integral comes back in proof 3, in the middle of the mgf.

Step 1: get rid of μ\mu and σ\sigma

By rule 2, with u=x−μσu = \frac{x – \mu}{\sigma}, dx=σ dudx = \sigma\,du:

∫−∞∞1σ2π e−(x−μ)22σ2 dx=∫−∞∞1σ2π e−u22 σ du=12π∫−∞∞e−u22 du \int_{-\infty}^{\infty} \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{(x-\mu)^2}{2\sigma^2}}\, dx = \int_{-\infty}^{\infty} \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{u^2}{2}}\, \sigma\,du = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{-\frac{u^2}{2}}\, du

The σ\sigma from dxdx cancels with the one in the denominator. So everything comes down to proving a single thing, which does not depend on the filling machine:

I=∫−∞∞e−x22 dx=2π I = \int_{-\infty}^{\infty} e^{-\frac{x^2}{2}}\, dx = \sqrt{2\pi}

Step 2: the problem with this integral

e−x2/2e^{-x^2/2} has no elementary antiderivative: there is no function you know whose derivative is that. The integral from −∞-\infty to ∞\infty can still be computed, with a trick nobody would think of the first time: compute I2I^2 instead of II.

I2=(∫−∞∞e−x22 dx)(∫−∞∞e−y22 dy)=∫−∞∞∫−∞∞e−x2+y22 dx dy I^2 = \left(\int_{-\infty}^{\infty} e^{-\frac{x^2}{2}}\, dx\right)\left(\int_{-\infty}^{\infty} e^{-\frac{y^2}{2}}\, dy\right) = \int_{-\infty}^{\infty}\int_{-\infty}^{\infty} e^{-\frac{x^2 + y^2}{2}}\, dx\, dy

In the second factor the variable is called yy (the name does not matter), and the product of two integrals of functions of different variables is the double integral of the product. Now the exponent is x2+y2x^2 + y^2: the squared distance from the point (x,y)(x, y) to the origin.

Why squaring helps: with a single variable there’s no antiderivative, but with two the exponent depends only on the distance to the origin, and polar coordinates are made for exactly that. The product of integrals is a double integral because e−x2/2 e−y2/2=e−(x2+y2)/2 e^{-x^2/2}\, e^{-y^2/2} = e^{-(x^2 + y^2)/2} . What you gain shows up in step 4: switching to polar brings an r r that is exactly the derivative of the exponent.

Step 3: switch to polar coordinates

Cutting the plane into ringsOn the left, the plane divided into little squares, darker near the center, where the function e to the minus x squared plus y squared over 2 is larger. On the right, the same plane divided into concentric rings: on each ring the function has the same value and its area grows with the radius r.Little squares: dx · dye^(−(x² + y²)/2)rRings: r · dr · dθon each ring, e^(−r²/2) is constantpolar
With rings the r that makes e^(−r²/2) integrable appears: that is where the 2π comes from.

With x=rcos⁡θx = r\cos\theta, y=rsin⁡θy = r\sin\theta, we have x2+y2=r2x^2 + y^2 = r^2 and the area element dx dydx\,dy becomes r dr dθr\,dr\,d\theta (a small piece of ring with radius rr, thickness drdr and angle dθd\theta has area r dθ⋅drr\,d\theta \cdot dr). The whole plane is covered with rr from 0 to ∞\infty and θ\theta from 0 to 2π2\pi:

I2=∫02π∫0∞e−r22 r dr dθ I^2 = \int_{0}^{2\pi}\int_{0}^{\infty} e^{-\frac{r^2}{2}}\, r\, dr\, d\theta

In the drawing: instead of cutting the plane into little squares, it is cut into rings. On each ring the function has the same value, and the area of the ring brings the rr we need.

Step 4: the integral that now works

That rr is the derivative (up to the sign) of the exponent: ddr(−e−r2/2)=r e−r2/2\frac{d}{dr}\left(-e^{-r^2/2}\right) = r\,e^{-r^2/2}. So:

∫0∞e−r22 r dr=[−e−r22]0∞=0−(−1)=1 \int_{0}^{\infty} e^{-\frac{r^2}{2}}\, r\, dr = \left[-e^{-\frac{r^2}{2}}\right]_{0}^{\infty} = 0 – (-1) = 1

And the integral in θ\theta of a constant 1 is the length of the interval:

I2=∫02π1 dθ=2π⟹I=2π I^2 = \int_{0}^{2\pi} 1\, d\theta = 2\pi \qquad\Longrightarrow\qquad I = \sqrt{2\pi}

We take the positive root because II is the integral of a positive function.

Step 5: back to the normal

With step 1:

∫−∞∞f(x) dx=12π⋅2π=1 \int_{-\infty}^{\infty} f(x)\, dx = \frac{1}{\sqrt{2\pi}} \cdot \sqrt{2\pi} = 1

Forgetting the rr in r dr dθr\,dr\,d\theta when switching to polar coordinates. Without it, the integral ∫0∞e−r2/2 dr\int_0^\infty e^{-r^2/2}\,dr is impossible again and you get stuck. The area of a small piece of ring grows with its radius: that is the rr.

Result for the cheat sheet. ∫−∞∞e−x2/2 dx=2π\int_{-\infty}^{\infty} e^{-x^2/2}\,dx = \sqrt{2\pi}, and in general ∫−∞∞e−(x−μ)22σ2 dx=σ2π\int_{-\infty}^{\infty} e^{-\frac{(x-\mu)^2}{2\sigma^2}}\,dx = \sigma\sqrt{2\pi}.

Check you’ve got it: what is ∫−∞∞e−(x−1010)272 dx \int_{-\infty}^{\infty} e^{-\frac{(x – 1010)^2}{72}}\, dx , and why isn’t it 1?

It’s 62π=15.04 6\sqrt{2\pi} = 15.04 . The denominator of the exponent is 2σ2=72 2\sigma^2 = 72 , so σ2=36 \sigma^2 = 36 and σ=6 \sigma = 6 : it’s the filling machine’s bell, but without the constant. By the general result for the cheat sheet, the area under e−(x−μ)22σ2 e^{-\frac{(x-\mu)^2}{2\sigma^2}} is σ2π \sigma\sqrt{2\pi} . It isn’t 1 because it’s missing the division by σ2π \sigma\sqrt{2\pi} , which is exactly what the last line of the R code below does.

Check it with R

I <- integrate(function(x) exp(-x^2 / 2), -Inf, Inf)$value
c(I, sqrt(2 * pi))                       # the Gaussian integral
integrate(dnorm, -Inf, Inf, mean = 1010, sd = 6)$value   # the filling machine: careful!
integrate(dnorm, 950, 1070, mean = 1010, sd = 6)$value    # with limits nearby
integrate(function(x) exp(-(x - 1010)^2 / 72), 950, 1070)$value / (6 * sqrt(2 * pi))

Output:

[1] 2.506628 2.506628
[1] 0
[1] 1
[1] 1

The first two numbers match (2.506628): the Gaussian integral is 2π\sqrt{2\pi}. The interesting part comes next. With -Inf and Inf, the integral for the filling machine comes out as 0, and not because the proof fails: integrate looks at the function at a few points spread over the whole line and, since the bell is very narrow and far from 0 (at 1010, with σ=6\sigma = 6), none of those points lands on it. It thinks the function is 0 everywhere. With limits 10 deviations from the mean, 950 and 1070, it gives 1. The last line writes the density by hand, with 2σ2=722\sigma^2 = 72, and divides it by σ2π\sigma\sqrt{2\pi}: also 1. integrate passes the arguments after the limits on to the function, which is why mean = 1010, sd = 6 reach dnorm.

Trusting integrate(…, -Inf, Inf) with a normal far from 0. If the result makes no sense (a 0 where there should be a 1), use finite limits that cover the bell: μ±10σ\mu \pm 10\sigma is plenty.

Proof 2: standardising both ways (theorem 5)

What we want to prove

The two parts of theorem 5 in the notes:

  1. If X∼N(0,1)X \sim N(0, 1) and Y=σX+μY = \sigma X + \mu, with σ>0\sigma > 0, then Y∼N(μ,σ)Y \sim N(\mu, \sigma).
  2. If X∼N(μ,σ)X \sim N(\mu, \sigma) and Z=X−μσZ = \frac{X – \mu}{\sigma}, then Z∼N(0,1)Z \sim N(0, 1).

Why it matters. This theorem is the reason a single table (or a single pnorm) is enough for every normal: any question about the filling machine translates into a question about Z Z . And part 1, X=μ+σZ X = \mu + \sigma Z , is the piece that proofs 3, 4 and 6 use to go from the standard normal to any normal.

Where we start

From the idea in topic 4 for changing variables: compute the distribution function of the new variable in terms of the old one and differentiate. You cannot differentiate the normal’s FF with a formula, but you do not need to: rule 5 says its derivative is ff.

Part 1: from ZZ to Y=σX+μY = \sigma X + \mu

YY takes values on the whole line (because XX does too). For every real yy:

FY(y)=P(Y≤y)=P(σX+μ≤y) F_Y(y) = P(Y \le y) = P(\sigma X + \mu \le y)

We subtract μ\mu from both sides and divide by σ\sigma. Since σ>0\sigma > 0, the inequality does not flip:

FY(y)=P(X≤y−μσ)=FX(y−μσ) F_Y(y) = P\left(X \le \frac{y – \mu}{\sigma}\right) = F_X\left(\frac{y – \mu}{\sigma}\right)

We differentiate with respect to yy using rule 5 (the derivative of y−μσ\frac{y – \mu}{\sigma} is 1σ\frac{1}{\sigma}):

fY(y)=fX(y−μσ)⋅1σ=1σ⋅12π e−12(y−μσ)2=1σ2π e−(y−μ)22σ2 f_Y(y) = f_X\left(\frac{y – \mu}{\sigma}\right) \cdot \frac{1}{\sigma} = \frac{1}{\sigma} \cdot \frac{1}{\sqrt{2\pi}}\, e^{-\frac{1}{2}\left(\frac{y – \mu}{\sigma}\right)^2} = \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{(y – \mu)^2}{2\sigma^2}}

Where the last step comes from: fX f_X is the standard density evaluated at y−μσ \frac{y – \mu}{\sigma} , and when you square it, (y−μσ)2=(y−μ)2σ2 \left(\frac{y – \mu}{\sigma}\right)^2 = \frac{(y – \mu)^2}{\sigma^2} . With the 12 \frac{1}{2} in front you get the 2σ2 2\sigma^2 in the denominator.

It is the density of an N(μ,σ)N(\mu, \sigma). And that is why X=μ+σZX = \mu + \sigma Z is the way to build any normal from the standard one.

Part 2: from XX to Z=X−μσZ = \frac{X – \mu}{\sigma}

The same, but backwards. For every real zz:

FZ(z)=P(X−μσ≤z)=P(X≤σz+μ)=FX(σz+μ) F_Z(z) = P\left(\frac{X – \mu}{\sigma} \le z\right) = P(X \le \sigma z + \mu) = F_X(\sigma z + \mu)

Multiplying by σ>0\sigma > 0 does not flip it either. We differentiate (the derivative of σz+μ\sigma z + \mu is σ\sigma):

fZ(z)=σ fX(σz+μ)=σ⋅1σ2π e−(σz+μ−μ)22σ2=12π e−z22 f_Z(z) = \sigma\, f_X(\sigma z + \mu) = \sigma \cdot \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{(\sigma z + \mu – \mu)^2}{2\sigma^2}} = \frac{1}{\sqrt{2\pi}}\, e^{-\frac{z^2}{2}}

The σ\sigmas cancel and the μ\mu disappears inside the square: what is left is the density of the N(0,1)N(0, 1).

Standardising in two stepsThree bells from left to right: the filling machine one, normal 1010 6, very low and centred at 1010; after subtracting 1010, normal 0 6, just as low but centred at 0; after dividing by 6, normal 0 1, centred at 0 and much taller, with peak 0.4.0.00.20.499010101030fX ~ N(1010, 6)-20020X − 1010 ~ N(0, 6)-303(X − 1010)/6 ~ N(0, 1)− μ÷ σSubtracting μ shifts (same shape); dividing by σ narrows and raises (area always 1).
The two parts of theorem 5 are this path in one direction (standardise) or the other (X = μ + σZ).

In the drawing, the two parts are the same path travelled in opposite directions: subtracting μ\mu shifts the bell to 0 and dividing by σ\sigma narrows it (or widens it) to σ=1\sigma = 1. The areas are preserved all along the way.

When solving inside the probability, forgetting the factor 1σ\frac{1}{\sigma} (or σ\sigma) from the chain rule. Without it, the “density” you get does not integrate to 1, and that works as a check: if the result is not exactly the density of a known normal, you have dropped a factor.

Result for the cheat sheet. X∼N(μ,σ)⇒Z=X−μσ∼N(0,1)X \sim N(\mu, \sigma) \Rightarrow Z = \frac{X – \mu}{\sigma} \sim N(0, 1); Z∼N(0,1)⇒X=μ+σZ∼N(μ,σ)Z \sim N(0, 1) \Rightarrow X = \mu + \sigma Z \sim N(\mu, \sigma); FX(x)=Φ(x−μσ)F_X(x) = \Phi\left(\frac{x – \mu}{\sigma}\right).

Check you’ve got it: if in part 1 we had σ<0 \sigma < 0 , for example Y=−6X+1010 Y = -6X + 1010 , what would change in the calculation and what distribution would you get?

Dividing by a negative number flips the inequality: P(−6X+1010≤y)=P(X≥y−1010−6)=1−FX(y−1010−6) P(-6X + 1010 \le y) = P\left(X \ge \frac{y – 1010}{-6}\right) = 1 – F_X\left(\frac{y – 1010}{-6}\right) . When you differentiate, the minus sign in front and the 1−6 \frac{1}{-6} from the chain rule cancel out: 16fX(y−1010−6) \frac{1}{6} f_X\left(\frac{y – 1010}{-6}\right) . Since the standard density is even, the sign of the argument doesn’t matter: you get N(1010,6) N(1010, 6) again. The standard deviation is ∣−6∣=6 \lvert -6 \rvert = 6 , which is what proof 5 proves in general.

Check it with R

set.seed(2026)
x <- rnorm(1e5, 1010, 6)           # a hundred thousand packets from the machine
z <- (x - 1010) / 6                # standardised
round(c(mean(z), sd(z)), 3)        # must come out as 0 and 1
round(quantile(z, c(0.05, 0.5, 0.95)), 3)   # simulated quantiles
round(qnorm(c(0.05, 0.5, 0.95)), 3)         # quantiles of the N(0, 1)

Output:

[1] 0.001 1.003
    5%    50%    95% 
-1.649  0.004  1.645 
[1] -1.645  0.000  1.645

The mean and standard deviation of the standardised packets come out as 0.001 and 1.003, that is, 0 and 1 up to simulation noise, and the simulated quantiles almost match those of the standard normal: the 5 % and 95 % ones are at ±1.64. It is part 2 seen with data.

Proof 3: the mgf, the mean and the variance (theorem 6)

What we want to prove

If X∼N(μ,σ)X \sim N(\mu, \sigma):

φX(t)=eμt+12σ2t2,E(X)=μ,Var(X)=σ2 \varphi_X(t) = e^{\mu t + \frac{1}{2}\sigma^2 t^2}, \qquad E(X) = \mu, \qquad \mathrm{Var}(X) = \sigma^2

Why it matters. Up to here, μ \mu and σ \sigma were two letters in the formula; this proof shows that they really are the mean and the standard deviation, and that’s why they’re called that. And the mgf is the tool of proofs 5 and 6.

Step 1: the mgf of the standard normal

For Z∼N(0,1)Z \sim N(0, 1), by definition:

φZ(t)=E(etZ)=∫−∞∞etz 12π e−z22 dz=12π∫−∞∞e−12(z2−2tz) dz \varphi_Z(t) = E\left(e^{tZ}\right) = \int_{-\infty}^{\infty} e^{tz}\, \frac{1}{\sqrt{2\pi}}\, e^{-\frac{z^2}{2}}\, dz = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty} e^{-\frac{1}{2}(z^2 – 2tz)}\, dz

The two exponentials have been joined: tz−z22=−12(z2−2tz)tz – \frac{z^2}{2} = -\frac{1}{2}(z^2 – 2tz). Now, by rule 4, z2−2tz=(z−t)2−t2z^2 – 2tz = (z – t)^2 – t^2:

φZ(t)=12π∫−∞∞e−12(z−t)2+12t2 dz=e12t2⋅12π∫−∞∞e−12(z−t)2 dz \varphi_Z(t) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty} e^{-\frac{1}{2}(z – t)^2 + \frac{1}{2}t^2}\, dz = e^{\frac{1}{2}t^2} \cdot \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty} e^{-\frac{1}{2}(z – t)^2}\, dz

The factor et2/2e^{t^2/2} comes outside because it does not depend on zz (rule 1). What is left inside is the density of an N(t,1)N(t, 1): it integrates to 1 by proof 1. So:

φZ(t)=e12t2 \varphi_Z(t) = e^{\frac{1}{2}t^2}
Completing the square: another bellIn violet, the standard normal density. In coral, that density multiplied by e to the t z with t equal to 1: it is another bell, centred at 1 and taller, whose shaded area is e to the one half, 1.649.0.00.20.40.6-4-20124zφ(z)e^(tz) φ(z) = e^(t²/2) · φ(z − t)area = e^(t²/2) = 1.649t = 1
Multiplying by e^(tz) shifts the bell to t and scales it by e^(t²/2): that factor is the mgf.

The drawing shows what completing the square does: multiplying the bell by etze^{tz} deforms it, but the result is a bell again, shifted to tt and taller. Its area is et2/2e^{t^2/2}, and that is the mgf.

Why complete the square

Step 1 fits in two lines, but it does six things. The same calculation, slowly:

StepWhat’s doneWhy
1etz e−z2/2=etz−z2/2 e^{tz}\, e^{-z^2/2} = e^{tz – z^2/2} When you multiply exponentials, the exponents add up
2tz−z22=−12(z2−2tz) tz – \frac{z^2}{2} = -\frac{1}{2}(z^2 – 2tz) You take out −12 -\frac{1}{2} so that z2 z^2 stands alone, as in the bell
3z2−2tz=(z−t)2−t2 z^2 – 2tz = (z – t)^2 – t^2 z2−2tz z^2 – 2tz isn’t a square; adding and subtracting t2 t^2 makes it one (rule 4)
4−12((z−t)2−t2)=−12(z−t)2+12t2 -\frac{1}{2}\left((z – t)^2 – t^2\right) = -\frac{1}{2}(z – t)^2 + \frac{1}{2}t^2 The −12 -\frac{1}{2} is distributed: the −t2 -t^2 changes sign
5et2/2 e^{t^2/2} comes out of the integralIt doesn’t depend on z z : it’s a constant (rule 1)
612π∫e−12(z−t)2 dz=1 \frac{1}{\sqrt{2\pi}}\int e^{-\frac{1}{2}(z – t)^2}\, dz = 1 It’s the density of an N(t,1) N(t, 1) : it integrates to 1 (proof 1)

The underlying idea: you don’t know how to integrate etz e^{tz} times the bell, but you do know the area of a bell. Completing the square turns the first into the second.

Step 2: the mean and variance of the standard normal

We differentiate (chain rule):

φZ′(t)=t e12t2⟹E(Z)=φZ′(0)=0 \varphi_Z'(t) = t\, e^{\frac{1}{2}t^2} \qquad\Longrightarrow\qquad E(Z) = \varphi_Z'(0) = 0
φZ′′(t)=e12t2+t2 e12t2⟹E(Z2)=φZ′′(0)=1 \varphi_Z''(t) = e^{\frac{1}{2}t^2} + t^2\, e^{\frac{1}{2}t^2} \qquad\Longrightarrow\qquad E(Z^2) = \varphi_Z''(0) = 1

The second derivative is that of a product: (t⋅et2/2)′=1⋅et2/2+t⋅t et2/2(t \cdot e^{t^2/2})' = 1 \cdot e^{t^2/2} + t \cdot t\,e^{t^2/2}. Therefore Var(Z)=E(Z2)−E(Z)2=1−0=1\mathrm{Var}(Z) = E(Z^2) – E(Z)^2 = 1 – 0 = 1.

Step 3: the mgf of any normal

By proof 2, X=μ+σZX = \mu + \sigma Z. By rule 6, with a=σa = \sigma and b=μb = \mu:

φX(t)=E(et(μ+σZ))=eμt E(e(σt)Z)=eμt φZ(σt)=eμt⋅e12σ2t2 \varphi_X(t) = E\left(e^{t(\mu + \sigma Z)}\right) = e^{\mu t}\, E\left(e^{(\sigma t) Z}\right) = e^{\mu t}\, \varphi_Z(\sigma t) = e^{\mu t} \cdot e^{\frac{1}{2}\sigma^2 t^2}

The step that gets skipped: E(e(σt)Z) E\left(e^{(\sigma t) Z}\right) is the mgf of Z Z evaluated at the point σt \sigma t instead of at t t . You replace t t with σt \sigma t in e12t2 e^{\frac{1}{2}t^2} , and 12(σt)2=12σ2t2 \frac{1}{2}(\sigma t)^2 = \frac{1}{2}\sigma^2 t^2 .

Here is the sign from the anecdote: with X=σZ−μX = \sigma Z – \mu you would have got e−μte^{-\mu t}. The check: at t=0t = 0 every mgf equals 1, and φX′(0)\varphi_X'(0) has to be the mean, which must be μ\mu and not −μ-\mu.

Step 4: the mean and the variance, two ways

With the mgf. Call g(t)=μt+12σ2t2g(t) = \mu t + \frac{1}{2}\sigma^2 t^2, so φX=eg\varphi_X = e^{g}, with g′(t)=μ+σ2tg'(t) = \mu + \sigma^2 t and g′′(t)=σ2g''(t) = \sigma^2:

φX′(t)=g′(t) eg(t)⟹E(X)=g′(0) e0=μ \varphi_X'(t) = g'(t)\, e^{g(t)} \qquad\Longrightarrow\qquad E(X) = g'(0)\,e^{0} = \mu
φX′′(t)=(g′′(t)+g′(t)2)eg(t)⟹E(X2)=σ2+μ2 \varphi_X''(t) = \left(g''(t) + g'(t)^2\right) e^{g(t)} \qquad\Longrightarrow\qquad E(X^2) = \sigma^2 + \mu^2
Var(X)=E(X2)−E(X)2=σ2+μ2−μ2=σ2 \mathrm{Var}(X) = E(X^2) – E(X)^2 = \sigma^2 + \mu^2 – \mu^2 = \sigma^2

Without the mgf. With X=μ+σZX = \mu + \sigma Z and rule 1:

E(X)=μ+σ E(Z)=μ+σ⋅0=μ,Var(X)=σ2 Var(Z)=σ2⋅1=σ2 E(X) = \mu + \sigma\, E(Z) = \mu + \sigma \cdot 0 = \mu, \qquad \mathrm{Var}(X) = \sigma^2\, \mathrm{Var}(Z) = \sigma^2 \cdot 1 = \sigma^2

Writing φX=eg\varphi_X = e^{g} saves a lot of work: the derivative of ege^{g} is g′egg'e^{g}, and the second, (g′′+g′2) eg(g'' + g'^2)\,e^{g}. At t=0t = 0, eg(0)=1e^{g(0)} = 1. The notes differentiate the product etμ⋅eσ2t2/2e^{t\mu}\cdot e^{\sigma^2t^2/2} term by term and get four terms; the result is the same.

E(Z)=0E(Z) = 0 also comes out without differentiating: z e−z2/2z\,e^{-z^2/2} is an odd function and, by rule 3, its integral is 0. It is the “by symmetry” reasoning the exam accepts if you justify it.

Computing E(X2)E(X^2) and giving it as the variance. φ′′(0)=σ2+μ2\varphi''(0) = \sigma^2 + \mu^2 is the second moment; the variance still needs μ2\mu^2 subtracted. With the filling machine, the difference is between 36 and more than a million.

Result for the cheat sheet. X∼N(μ,σ)X \sim N(\mu, \sigma): φX(t)=eμt+12σ2t2\varphi_X(t) = e^{\mu t + \frac{1}{2}\sigma^2t^2} for every tt; E(X)=μE(X) = \mu, Var(X)=σ2\mathrm{Var}(X) = \sigma^2, E(X2)=μ2+σ2E(X^2) = \mu^2 + \sigma^2.

Check you’ve got it: if you’re told a variable has mgf φ(t)=e1010t+18t2 \varphi(t) = e^{1010t + 18t^2} , what distribution does it have?

Compare it with the form eμt+12σ2t2 e^{\mu t + \frac{1}{2}\sigma^2 t^2} term by term. The coefficient of t t is the mean: μ=1010 \mu = 1010 . The coefficient of t2 t^2 is half the variance: 12σ2=18 \frac{1}{2}\sigma^2 = 18 , so σ2=36 \sigma^2 = 36 and σ=6 \sigma = 6 . By the uniqueness of the mgf, it’s N(1010,6) N(1010, 6) , the filling machine. The typical mistake is reading the 18 as the variance and giving σ=4.24 \sigma = 4.24 .

Check it with R

f <- function(x) dnorm(x, 1010, 6)
m1 <- integrate(function(x) x * f(x), 950, 1070)$value      # E(X)
m2 <- integrate(function(x) x^2 * f(x), 950, 1070)$value    # E(X^2)
round(c(m1, m2 - m1^2), 4)                                   # mean and variance
t <- 0.05                                                    # the mgf at t = 0.05
num <- integrate(function(x) exp(t * x) * f(x), 950, 1070)$value
c(num, exp(1010 * t + 0.5 * 36 * t^2))                       # integral and formula

Output:

[1] 1010   36
[1] 8.941587e+21 8.941587e+21

The mean comes out as 1010 and the variance as 36 (to four decimals). The last two figures are the mgf at t=0.05t = 0.05 computed by integrating and with the formula: they match. We integrate between 950 and 1070, 10 deviations from the mean, because outside that range the density is so small it adds nothing, and exp(t * x) up to infinity would cause numerical trouble (the warning from the previous topic).

Proof 4: symmetry, median, mode and inflection

What we want to prove

If X∼N(μ,σ)X \sim N(\mu, \sigma):

  1. The density is symmetric about μ\mu: f(μ+h)=f(μ−h)f(\mu + h) = f(\mu – h) for every hh. In the standard normal, ff is an even function.
  2. The median is μ\mu.
  3. The mode is μ\mu.
  4. The inflection points are μ−σ\mu – \sigma and μ+σ\mu + \sigma.

Why it matters. These four properties are behind every “by symmetry” in the exam. Symmetry gives Φ(−z)=1−Φ(z) \Phi(-z) = 1 – \Phi(z) , which is why tables only list positive z z ; the inflection points give you a way to read σ \sigma off a graph.

Symmetry

We substitute into the formula:

f(μ+h)=1σ2π e−h22σ2,f(μ−h)=1σ2π e−(−h)22σ2=1σ2π e−h22σ2 f(\mu + h) = \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{h^2}{2\sigma^2}}, \qquad f(\mu – h) = \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{(-h)^2}{2\sigma^2}} = \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{h^2}{2\sigma^2}}

They are equal because (−h)2=h2(-h)^2 = h^2. In the standard normal (μ=0\mu = 0) this says f(−z)=f(z)f(-z) = f(z): the density is even.

The median

In the standard normal, by rule 3 (the density is even):

1=∫−∞∞12π e−z22 dz=2∫−∞012π e−z22 dz=2 P(Z≤0) 1 = \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}}\, e^{-\frac{z^2}{2}}\, dz = 2\int_{-\infty}^{0} \frac{1}{\sqrt{2\pi}}\, e^{-\frac{z^2}{2}}\, dz = 2\,P(Z \le 0)

So P(Z≤0)=12P(Z \le 0) = \frac{1}{2}: the median of ZZ is 0. For X∼N(μ,σ)X \sim N(\mu, \sigma), the median is the xx with P(X≤x)=12P(X \le x) = \frac{1}{2}. Standardising (proof 2):

P(X≤x)=Φ(x−μσ)=12  ⟹  x−μσ=0  ⟹  x=μ P(X \le x) = \Phi\left(\frac{x – \mu}{\sigma}\right) = \frac{1}{2} \;\Longrightarrow\; \frac{x – \mu}{\sigma} = 0 \;\Longrightarrow\; x = \mu

The middle step uses that Φ\Phi is strictly increasing, so the only point where it equals 12\frac{1}{2} is 0.

The mode

The mode is the maximum of ff. Since the logarithm is increasing, ff and log⁡f\log f have their maximum at the same place, and log⁡f\log f is much easier to differentiate (the trick from topic 4):

log⁡f(x)=−log⁡σ−12log⁡(2π)−(x−μ)22σ2 \log f(x) = -\log\sigma – \frac{1}{2}\log(2\pi) – \frac{(x – \mu)^2}{2\sigma^2}
ddxlog⁡f(x)=−x−μσ2=0  ⟺  x=μ \frac{d}{dx}\log f(x) = -\frac{x – \mu}{\sigma^2} = 0 \iff x = \mu

It is a maximum because the second derivative of log⁡f\log f is −1σ2<0-\frac{1}{\sigma^2} < 0. For the filling machine, the most frequent weight is 1010 g, the mean.

The inflection points

Now we do have to differentiate ff twice. The first time, by the chain rule:

f′(x)=−x−μσ2 f(x) f'(x) = -\frac{x – \mu}{\sigma^2}\, f(x)

Where it comes from: f f is a constant times eg(x) e^{g(x)} , with g(x)=−(x−μ)22σ2 g(x) = -\frac{(x – \mu)^2}{2\sigma^2} , and the derivative of eg e^{g} is g′ eg g'\,e^{g} . Since g′(x)=−2(x−μ)2σ2=−x−μσ2 g'(x) = -\frac{2(x – \mu)}{2\sigma^2} = -\frac{x – \mu}{\sigma^2} , f f itself shows up again, multiplied.

The second, differentiating that product:

f′′(x)=−1σ2 f(x)−x−μσ2 f′(x)=−1σ2 f(x)+(x−μ)2σ4 f(x)=f(x)σ2((x−μ)2σ2−1) f''(x) = -\frac{1}{\sigma^2}\, f(x) – \frac{x – \mu}{\sigma^2}\, f'(x) = -\frac{1}{\sigma^2}\, f(x) + \frac{(x – \mu)^2}{\sigma^4}\, f(x) = \frac{f(x)}{\sigma^2}\left(\frac{(x – \mu)^2}{\sigma^2} – 1\right)

Since f(x)>0f(x) > 0, the sign of f′′f'' is that of the bracket: negative if ∣x−μ∣<σ|x – \mu| < \sigma (the curve bends down) and positive if ∣x−μ∣>σ|x – \mu| > \sigma (it bends up). It changes sign exactly at

(x−μ)2=σ2  ⟺  x=μ±σ (x – \mu)^2 = \sigma^2 \iff x = \mu \pm \sigma
Where the curvature changesThe filling machine bell over three bands: between 1004 and 1016, in violet, the second derivative is negative and the curve is concave; outside, in coral, it is positive and the curve is convex. The inflection points, at 1004 and 1016, are one standard deviation from 1010.0.000.020.040.0699299810041010101610221028Weight, in gramsf(x)f'' < 0concavef'' > 0convexf'' > 0convex10041016
The sign of f'' is that of (x − μ)²/σ² − 1: it changes exactly at μ ± σ.

In the drawing of the filling machine: between 1004 and 1016 the curve is concave (f′′<0f'' < 0, violet zone) and outside it is convex (f′′>0f'' > 0, coral zone). The inflection points are the way to see σ\sigma on the graph without any calculation.

In f′′f'', differentiating −x−μσ2 f(x)-\frac{x – \mu}{\sigma^2}\,f(x) as if f(x)f(x) were a constant. It is a product of two functions of xx: you get two terms, and the second uses f′f', which you already had.

Result for the cheat sheet. Mean = median = mode = μ\mu; inflection points at μ±σ\mu \pm \sigma; Φ(−z)=1−Φ(z)\Phi(-z) = 1 – \Phi(z).

Check you’ve got it: for the filling machine, P(X≤1016)=0.84 P(X \le 1016) = 0.84 . Without using R, what is P(X≤1004) P(X \le 1004) ?

0.16. 1004 and 1016 are the same distance from the mean, 6 g below and 6 g above. By symmetry, the left tail below 1004 has the same area as the right tail above 1016: P(X≤1004)=P(X≥1016)=1−0.84=0.16 P(X \le 1004) = P(X \ge 1016) = 1 – 0.84 = 0.16 . It’s Φ(−1)=1−Φ(1) \Phi(-1) = 1 – \Phi(1) in the filling machine’s grams.

Check it with R

f <- function(x) dnorm(x, 1010, 6)
optimize(f, c(980, 1040), maximum = TRUE)$maximum   # the mode
pnorm(1010, 1010, 6)                                # P(X <= mu)
h <- 1e-3                                           # f'' with differences
f2 <- function(x) (f(x + h) - 2 * f(x) + f(x - h)) / h^2
signif(f2(c(1003, 1004.5, 1015.5, 1017)), 3)        # +, -, -, +

Output:

[1] 1010
[1] 0.5
[1]  0.000338 -0.000194 -0.000194  0.000338

optimize finds the maximum at 1010, pnorm at the mean gives exactly 0.5, and the approximate second derivative is positive outside [1004,1016][1004, 1016] and negative inside, as the bracket says.

Proof 5: aX + b is normal

What we want to prove

If X∼N(μ,σ)X \sim N(\mu, \sigma) and a≠0a \ne 0, bb are real numbers:

aX+b∼N(aμ+b, ∣a∣ σ) aX + b \sim N\big(a\mu + b,\ |a|\,\sigma\big)

It is the mgf exercise from the topic 4 proposed exercises, and what you use when changing units.

Why it matters. Every time you change units, from grams to kilos or to “grams given away”, you’re doing an aX+b aX + b , and this proof guarantees you don’t have to work out the distribution again: it’s still normal. And proof 6 uses it with a=−1 a = -1 (the difference) and with a=1n a = \frac{1}{n} (the mean).

Where we start

From rule 6: the mgf of aX+baX + b is written in terms of that of XX, and if it has the form of the mgf of a normal, it is a normal (by uniqueness).

Step by step

φaX+b(t)=E(et(aX+b))=E(ebt e(at)X)=ebt E(e(at)X)=ebt φX(at) \varphi_{aX+b}(t) = E\left(e^{t(aX + b)}\right) = E\left(e^{bt}\, e^{(at)X}\right) = e^{bt}\, E\left(e^{(at)X}\right) = e^{bt}\, \varphi_X(at)

The ebte^{bt} comes out of the expectation because it is a constant (rule 1). We substitute the normal mgf at the point atat:

φaX+b(t)=ebt eμ(at)+12σ2(at)2=e(aμ+b)t+12(a2σ2)t2 \varphi_{aX+b}(t) = e^{bt}\, e^{\mu(at) + \frac{1}{2}\sigma^2 (at)^2} = e^{(a\mu + b)t + \frac{1}{2}(a^2\sigma^2)t^2}

How it’s grouped: μ(at)=aμ t \mu(at) = a\mu\, t and 12σ2(at)2=12a2σ2t2 \frac{1}{2}\sigma^2(at)^2 = \frac{1}{2}a^2\sigma^2 t^2 . The ebt e^{bt} is added to the exponent, and the two terms in t t are combined: bt+aμ t=(aμ+b)t bt + a\mu\, t = (a\mu + b)t .

It has the form emt+12s2t2e^{m t + \frac{1}{2}s^2 t^2} with m=aμ+bm = a\mu + b and s2=a2σ2s^2 = a^2\sigma^2. By the uniqueness of the mgf (rule 6), aX+baX + b is normal with mean aμ+ba\mu + b and standard deviation s=a2σ2=∣a∣ σs = \sqrt{a^2\sigma^2} = |a|\,\sigma.

Writing the standard deviation as aσa\sigma. If aa is negative (for example, −X-X), aσa\sigma would be negative, and a standard deviation never is. What changes sign is the mean; the spread is ∣a∣σ|a|\sigma.

The filling machine in kilos and the gofio “given away”

With a=11000a = \frac{1}{1000}, b=0b = 0: Y=X/1000∼N(1.010, 0.006)Y = X/1000 \sim N(1.010,\ 0.006), the weight in kilos. With a=1a = 1, b=−1000b = -1000: X−1000∼N(10,6)X – 1000 \sim N(10, 6), the grams given away (negative if the packet falls short). And P(X−1000<0)=P(X<1000)P(X – 1000 < 0) = P(X < 1000), the same probability as always: changing scale does not change the events.

Result for the cheat sheet. X∼N(μ,σ)⇒aX+b∼N(aμ+b, ∣a∣σ)X \sim N(\mu, \sigma) \Rightarrow aX + b \sim N(a\mu + b,\ |a|\sigma). With a=1σa = \frac{1}{\sigma} and b=−μσb = -\frac{\mu}{\sigma} you get standardisation.

Check you’ve got it: what distribution does Y=1010−X Y = 1010 – X have, how much each packet falls short of the mean?

It’s aX+b aX + b with a=−1 a = -1 and b=1010 b = 1010 . The mean is aμ+b=−1010+1010=0 a\mu + b = -1010 + 1010 = 0 and the standard deviation, ∣−1∣⋅6=6 \lvert -1 \rvert \cdot 6 = 6 . So Y∼N(0,6) Y \sim N(0, 6) . Subtracting from 1010 centres the bell at 0 and flips it, but it doesn’t make it narrower or wider.

Check it with R

set.seed(2026)
x <- rnorm(1e5, 1010, 6)
kg <- x / 1000                          # a = 1/1000, b = 0
gift <- x - 1000                        # a = 1, b = -1000
round(c(mean(kg), sd(kg)), 4)           # 1.010 and 0.006
round(c(mean(gift), sd(gift)), 2)       # 10 and 6
round(c(mean(-x), sd(-x)), 2)           # a = -1: mean -1010, sd 6

Output:

[1] 1.010 0.006
[1] 10.01  6.02
[1] -1010.01     6.02

Each transformation behaves as the formula says: in kilos the standard deviation is divided by a thousand; subtracting 1000 does not change it; and with a=−1a = -1 the mean changes sign, but the standard deviation stays positive.

Proof 6: the sum and difference of independent normals

What we want to prove

If X∼N(μ1,σ1)X \sim N(\mu_1, \sigma_1) and Y∼N(μ2,σ2)Y \sim N(\mu_2, \sigma_2) are independent:

X+Y∼N(μ1+μ2, σ12+σ22),X−Y∼N(μ1−μ2, σ12+σ22) X + Y \sim N\left(\mu_1 + \mu_2,\ \sqrt{\sigma_1^2 + \sigma_2^2}\right), \qquad X – Y \sim N\left(\mu_1 – \mu_2,\ \sqrt{\sigma_1^2 + \sigma_2^2}\right)

And, in general, if X1,…,XnX_1, \dots, X_n are independent and N(μ,σ)N(\mu, \sigma), their sum is N(nμ,σn)N(n\mu, \sigma\sqrt{n}) and their mean N(μ,σ/n)N(\mu, \sigma/\sqrt{n}).

Why it matters. A box of packets is a sum, comparing two filling machines is a difference, and the mean of a sample is a sum divided by n n . This last result, Xˉ∼N(μ,σ/n) \bar{X} \sim N(\mu, \sigma/\sqrt{n}) , is the basis of sampling and of confidence intervals.

The sum

By rule 6, since they are independent, the mgf of the sum is the product:

φX+Y(t)=φX(t) φY(t)=eμ1t+12σ12t2  eμ2t+12σ22t2=e(μ1+μ2)t+12(σ12+σ22)t2 \varphi_{X+Y}(t) = \varphi_X(t)\,\varphi_Y(t) = e^{\mu_1 t + \frac{1}{2}\sigma_1^2 t^2}\; e^{\mu_2 t + \frac{1}{2}\sigma_2^2 t^2} = e^{(\mu_1 + \mu_2)t + \frac{1}{2}(\sigma_1^2 + \sigma_2^2)t^2}

When multiplying exponentials the exponents add, and the terms in tt and t2t^2 are grouped. It is the mgf of a normal with mean μ1+μ2\mu_1 + \mu_2 and variance σ12+σ22\sigma_1^2 + \sigma_2^2. By uniqueness, done.

The difference

X−Y=X+(−Y)X – Y = X + (-Y). By proof 5 with a=−1a = -1, b=0b = 0: −Y∼N(−μ2,σ2)-Y \sim N(-\mu_2, \sigma_2), and it is still independent of XX. We apply the sum:

X−Y∼N(μ1+(−μ2), σ12+σ22) X – Y \sim N\left(\mu_1 + (-\mu_2),\ \sqrt{\sigma_1^2 + \sigma_2^2}\right)

The variance of −Y-Y is (−1)2σ22=σ22(-1)^2\sigma_2^2 = \sigma_2^2: that is why when subtracting, the variances also add.

The standard deviation of a difference is a hypotenuseRight triangle with legs 6 and 4, the standard deviations of the two machines, and hypotenuse root of 36 plus 16, 7.21, in coral: it is the standard deviation of the difference. On the right, three calculations: adding the standard deviations, 10, and subtracting them, 2, are wrong; adding the variances and taking the root, 7.21, is right.σ_A = 6σ_B = 4√(36 + 16) = 7.21Add the sds6 + 4 = 10errors always togetherSubtract the sds6 − 4 = 2errors that cancelAdd variances√(6² + 4²) = 7.21independentX_A − X_B, independent
With independent variables, standard deviations combine like the legs of a triangle.

The two machines in the drawing: σA=6\sigma_A = 6, σB=4\sigma_B = 4. The standard deviation of the difference is the hypotenuse of a right triangle with those legs, 36+16=7.21\sqrt{36 + 16} = 7.21. Neither 6+4=106 + 4 = 10 (which would assume the errors always go together) nor 6−4=26 – 4 = 2 (which would assume they cancel out).

Many at once, and the mean

With nn independent N(μ,σ)N(\mu, \sigma), applying the sum n−1n – 1 times (or multiplying nn equal mgfs):

φX1+⋯+Xn(t)=(eμt+12σ2t2)n=enμt+12nσ2t2  ⟹  X1+⋯+Xn∼N(nμ, σn) \varphi_{X_1 + \cdots + X_n}(t) = \left(e^{\mu t + \frac{1}{2}\sigma^2 t^2}\right)^n = e^{n\mu t + \frac{1}{2}n\sigma^2 t^2} \;\Longrightarrow\; X_1 + \cdots + X_n \sim N\left(n\mu,\ \sigma\sqrt{n}\right)

And the mean is the sum multiplied by a=1na = \frac{1}{n} (proof 5):

Xˉ∼N(nμn, σnn)=N(μ, σn) \bar{X} \sim N\left(\frac{n\mu}{n},\ \frac{\sigma\sqrt{n}}{n}\right) = N\left(\mu,\ \frac{\sigma}{\sqrt{n}}\right)

Where the roots come from: the sum of n n has variance nσ2 n\sigma^2 , so its standard deviation is nσ2=σn \sqrt{n\sigma^2} = \sigma\sqrt{n} . When you divide by n n , since n=n⋅n n = \sqrt{n}\cdot\sqrt{n} , you get σnn=σn \frac{\sigma\sqrt{n}}{n} = \frac{\sigma}{\sqrt{n}} .

The box of 12 packets: N(12120, 612)=N(12120, 20.78)N(12120,\ 6\sqrt{12}) = N(12120,\ 20.78). The mean of 9 packets: N(1010, 6/3)=N(1010, 2)N(1010,\ 6/3) = N(1010,\ 2).

Using the result without the word independent. If two packets come from the same batch and the moisture affects both in the same way, their weights are correlated and the variance of the sum is no longer the sum of the variances (it is missing the covariance, which you will see in topic 6). In the exam, cite independence at the step where you use it.

Result for the cheat sheet. X,YX, Y independent and normal: X±Y∼N(μ1±μ2, σ12+σ22)X \pm Y \sim N(\mu_1 \pm \mu_2,\ \sqrt{\sigma_1^2 + \sigma_2^2}). nn independent N(μ,σ)N(\mu, \sigma): sum N(nμ,σn)N(n\mu, \sigma\sqrt{n}), mean N(μ,σ/n)N(\mu, \sigma/\sqrt{n}).

Check you’ve got it: why does the box of 12 packets have standard deviation 20.78 and not 12⋅6=72 12 \cdot 6 = 72 ?

Because 72 would be the standard deviation of 12X 12X , a single packet multiplied by 12 (proof 5 with a=12 a = 12 ): as if the 12 packets always weighed the same and their errors went hand in hand. With independent packets, some go over and others fall short, and they compensate. What adds up are the variances: 12⋅36=432 12 \cdot 36 = 432 , and 432=20.78 \sqrt{432} = 20.78 .

Check it with R

set.seed(2026)
A <- rnorm(1e5, 1010, 6); B <- rnorm(1e5, 1004, 4)
round(c(mean(A - B), sd(A - B), sqrt(6^2 + 4^2)), 3)    # difference
box <- replicate(2e4, sum(rnorm(12, 1010, 6)))
round(c(mean(box), sd(box), 6 * sqrt(12)), 2)           # sum of 12
means <- replicate(2e4, mean(rnorm(9, 1010, 6)))
round(c(mean(means), sd(means)), 3)                      # mean of 9: sd 2

Output:

[1] 5.998 7.228 7.211
[1] 12119.94    20.64    20.78
[1] 1010.005    1.999

The difference of the two simulated machines has standard deviation 7.21, the hypotenuse; the box of 12, a standard deviation close to 20.78; and the means of 9 packets spread with standard deviation 1.999, almost 2. The simulated figures (7.228, 20.64 and 1.999) differ from the theoretical ones in the tenths or hundredths, which is simulation noise.

Prove it yourself

Three exercises in the style of the proposed exercises. Try each one before opening the solution.

  1. Let X∼N(μ,σ)X \sim N(\mu, \sigma) and c>0c > 0. Prove that P(∣X−μ∣≤cσ)=2Φ(c)−1P(|X – \mu| \le c\sigma) = 2\Phi(c) – 1, which therefore does not depend on μ\mu or σ\sigma, and find with R the cc for which it equals 0.5. What does it mean for the filling machine?
Show the solution to exercise 1

The absolute value is an interval: ∣X−μ∣≤cσ  ⟺  −cσ≤X−μ≤cσ|X – \mu| \le c\sigma \iff -c\sigma \le X – \mu \le c\sigma. Dividing by σ>0\sigma > 0 (the direction does not change) gives the standardised Z=X−μσ∼N(0,1)Z = \frac{X – \mu}{\sigma} \sim N(0, 1) (proof 2):

P(∣X−μ∣≤cσ)=P(−c≤Z≤c)=Φ(c)−Φ(−c) P(|X – \mu| \le c\sigma) = P(-c \le Z \le c) = \Phi(c) – \Phi(-c)

By symmetry (proof 4), Φ(−c)=1−Φ(c)\Phi(-c) = 1 – \Phi(c), leaving Φ(c)−(1−Φ(c))=2Φ(c)−1\Phi(c) – (1 – \Phi(c)) = 2\Phi(c) – 1. It only depends on cc. For it to equal 0.5: 2Φ(c)−1=0.5  ⟺  Φ(c)=0.75  ⟺  c=z0.752\Phi(c) – 1 = 0.5 \iff \Phi(c) = 0.75 \iff c = z_{0.75}, and qnorm(0.75) gives 0.6745. For the filling machine: half of the packets are less than 0.6745⋅6=4.050.6745 \cdot 6 = 4.05 g from 1010, between 1005.95 and 1014.05 g. That is why 0.6745 σ0.6745\,\sigma is sometimes called the “probable error”.

  1. Using the mgf of the standard normal, φZ(t)=et2/2\varphi_Z(t) = e^{t^2/2}, compute E(Z3)E(Z^3) and E(Z4)E(Z^4). Deduce that, for any normal, E((X−μ)4)=3σ4E\big((X – \mu)^4\big) = 3\sigma^4.
Show the solution to exercise 2

Instead of differentiating four times, expand it as a series, which is the mgf trick from topic 3: eu=1+u+u22!+⋯e^{u} = 1 + u + \frac{u^2}{2!} + \cdots with u=t22u = \frac{t^2}{2}:

φZ(t)=1+t22+t48+t648+⋯ \varphi_Z(t) = 1 + \frac{t^2}{2} + \frac{t^4}{8} + \frac{t^6}{48} + \cdots

On the other hand, φZ(t)=∑kE(Zk)tkk!\varphi_Z(t) = \sum_k E(Z^k)\frac{t^k}{k!}. Comparing coefficients: there is no t3t^3 term, so E(Z3)=0E(Z^3) = 0 (also by rule 3: z3z^3 times an even density is odd). The t4t^4 coefficient is E(Z4)4!=18\frac{E(Z^4)}{4!} = \frac{1}{8}, so E(Z4)=248=3E(Z^4) = \frac{24}{8} = 3. For X=μ+σZX = \mu + \sigma Z: X−μ=σZX – \mu = \sigma Z and E((X−μ)4)=σ4E(Z4)=3σ4E\big((X – \mu)^4\big) = \sigma^4 E(Z^4) = 3\sigma^4. Divided by σ4\sigma^4, the kurtosis coefficient of any normal is 3, which is the benchmark data are compared against in descriptive statistics. Check: integrate(function(z) z^4 * dnorm(z), -Inf, Inf) gives 3.

  1. Let X∼N(μ,σ)X \sim N(\mu, \sigma) and Y=eXY = e^{X} (the lognormal distribution). Without integrating, compute E(Y)E(Y). Apply it to X∼N(0,0.5)X \sim N(0, 0.5) and compare it with eE(X)e^{E(X)}.
Show the solution to exercise 3

E(Y)=E(eX)=E(e1⋅X)=φX(1)E(Y) = E(e^{X}) = E(e^{1 \cdot X}) = \varphi_X(1): the mgf evaluated at t=1t = 1. With the formula from theorem 6:

E(eX)=φX(1)=eμ+12σ2 E\left(e^{X}\right) = \varphi_X(1) = e^{\mu + \frac{1}{2}\sigma^2}

With μ=0\mu = 0, σ=0.5\sigma = 0.5: E(Y)=e0.125=1.1331E(Y) = e^{0.125} = 1.1331, while eE(X)=e0=1e^{E(X)} = e^{0} = 1. The mean of the exponential is not the exponential of the mean: the 12σ2\frac{1}{2}\sigma^2 term appears because exe^{x} grows faster to the right than it falls to the left. In R, mean(exp(rnorm(1e6, 0, 0.5))) gives 1.13 and exp(0.125) gives 1.1331. The proposed exercises of topic 5 use the lognormal for incomes and file sizes; in R it is dlnorm, plnorm, qlnorm and rlnorm.

When to use each result

If you are asked for…UseWatch out for…
The density integrating to 1, or an integral with e−x2e^{-x^2}The Gaussian integral and a change of variable (proof 1)The rr of polar coordinates
The distribution of X−μσ\frac{X – \mu}{\sigma} or of μ+σZ\mu + \sigma ZFF of the new one in terms of the old one, then differentiate (proof 2)The chain-rule factor
The mgf, mean or variance of a normalCompleting the square, or X=μ+σZX = \mu + \sigma Z (proof 3)E(X2)E(X^2) is not the variance
The median, mode, symmetry or inflectionEvenness, log⁡f\log f and f′′f'' (proof 4)f′′f'' is the derivative of a product
The distribution of aX+baX + bThe mgf and its uniqueness (proof 5)∣a∣σ\lvert a\rvert\sigma, not aσa\sigma
The distribution of a sum, difference or meanProduct of mgfs of independents (proof 6)Saying they are independent
A higher moment, E(Z4)E(Z^4)The mgf series (Prove it yourself, 2)Dividing by k!k!
E(eX)E(e^{X})The mgf at t=1t = 1 (Prove it yourself, 3)It is not eE(X)e^{E(X)}

Common mistakes when proving

  • Solving the standardisation the wrong way. X=μ+σZX = \mu + \sigma Z. Check with Z=0Z = 0 (you get the mean) and with Z=1Z = 1 (one deviation above).
  • Flipping the inequality for no reason. Dividing by σ>0\sigma > 0 keeps the direction; it only flips when multiplying by a negative number, as in −X-X.
  • Forgetting the rr of polar coordinates in the Gaussian integral, or the σ\sigma of the change of variable.
  • Mixing up the second moment with the variance: φ′′(0)=μ2+σ2\varphi''(0) = \mu^2 + \sigma^2.
  • Concluding that something is normal because it “looks like it”. The proof ends when the mgf has exactly the form emt+12s2t2e^{mt + \frac{1}{2}s^2t^2} and uniqueness is cited.
  • Adding normals without saying they are independent, or subtracting their variances when subtracting the variables.

Try it in the R playground

Open the site’s R playground (or RStudio) and paste this script. It checks the six proofs with integrals and simulations:

# 1. The Gaussian integral
integrate(function(x) exp(-x^2 / 2), -Inf, Inf)$value; sqrt(2 * pi)
# 2. Standardising: the standardised packets are N(0, 1)
x <- rnorm(1e5, 1010, 6); z <- (x - 1010) / 6
c(mean(z), sd(z))
# 3. The mgf at t = 0.05, by integrating and with the formula
integrate(function(x) exp(0.05 * x) * dnorm(x, 1010, 6), 950, 1070)$value
exp(1010 * 0.05 + 0.5 * 36 * 0.05^2)
# 4. Mode and median at the mean
optimize(function(x) dnorm(x, 1010, 6), c(980, 1040), maximum = TRUE)$maximum
pnorm(1010, 1010, 6)
# 5 and 6. Change of scale, difference and box of 12
c(sd(x / 1000), sd(x - rnorm(1e5, 1004, 4)), sd(replicate(1e4, sum(rnorm(12, 1010, 6)))))

What to look at:

  1. In the first line, the two equal numbers: 2.506628. It is the 2π\sqrt{2\pi} of the constant.
  2. Change the 6 in rnorm to 10 and run block 2 again: sd(z) still comes out as 1 if you also change the 6 in the standardisation. If you do not, you get 1.67: you have standardised with the wrong deviation.
  3. In block 3, change 0.05 to 0.1: the formula and the integral still match, even though the number is huge.
  4. In the last line, the three numbers are 0.006, 7.21 and 20.78 (give or take simulation noise). Write the three formulas yourself before looking at them.
  5. Add hist(z, freq = FALSE); curve(dnorm(x), add = TRUE) and look in Plots at how the standard bell fits the standardised packets.

Summary

ResultFormulaHow it is proved
Gaussian integral∫e−x2/2dx=2π\int e^{-x^2/2}dx = \sqrt{2\pi}I2I^2 in polar coordinates
StandardisingZ=X−μσ∼N(0,1)Z = \frac{X – \mu}{\sigma} \sim N(0,1), X=μ+σZX = \mu + \sigma ZFF of the new one, then differentiate
mgfeμt+12σ2t2e^{\mu t + \frac{1}{2}\sigma^2t^2}Completing the square
MomentsE(X)=μE(X) = \mu, Var(X)=σ2\mathrm{Var}(X) = \sigma^2Differentiating the mgf, or linearity
ShapeMean = median = mode = μ\mu; inflection at μ±σ\mu \pm \sigmaEvenness, log⁡f\log f, f′′f''
ScaleaX+b∼N(aμ+b,∣a∣σ)aX + b \sim N(a\mu + b, \lvert a\rvert\sigma)mgf and uniqueness
Sum and differenceN(μ1±μ2,σ12+σ22)N(\mu_1 \pm \mu_2, \sqrt{\sigma_1^2 + \sigma_2^2})Product of mgfs
Mean of nnN(μ,σ/n)N(\mu, \sigma/\sqrt{n})Sum times 1n\frac{1}{n}

Three ideas to take away:

  1. Almost everything comes from two pieces: X=μ+σZX = \mu + \sigma Z and the mgf. With the first you go from the standard normal to any normal; with the second you prove that a linear combination is still normal.
  2. Completing the square is the normal’s trick: it turns an impossible integral into the area of another bell, which is worth what you already know.
  3. Variances rule: they are multiplied by a2a^2 when changing scale and they add when adding or subtracting independents. The standard deviation is computed at the end, with the square root.

Now it is time to do it with R: in the normal distribution practice you simulate 10,000 packets, check whether the data from a scale are normal and adjust the machine. And in the exercises, these proofs appear as exam questions.

Next step: practiceThe normal distribution — R practice with 10,000 gofio packets, a scale and boxes of 12 (and the curve stuck to the floor)

Did this article help you? Here is how you can support SergioLearns →