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 instead of , and that sign was dragged all the way to the end, where gave a negative mean. Since then, before using I check that 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, . 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.
Table of Contents
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”).
- Linearity of the integral and of expectation. , and therefore and .
- Linear change of variable. If , with , then , , and the limits and stay and .
- Even and odd functions. If (even), . If (odd) and the integral exists, .
- Completing the square. . Check it by expanding: .
- Fundamental theorem of calculus and chain rule. If is the distribution function of a continuous variable, ; and .
- Properties of the mgf. ; ; if and are independent, ; ; 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:
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 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 and
By rule 2, with , :
The from cancels with the one in the denominator. So everything comes down to proving a single thing, which does not depend on the filling machine:
Step 2: the problem with this integral
has no elementary antiderivative: there is no function you know whose derivative is that. The integral from to can still be computed, with a trick nobody would think of the first time: compute instead of .
In the second factor the variable is called (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 : the squared distance from the point 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 . What you gain shows up in step 4: switching to polar brings an that is exactly the derivative of the exponent.
Step 3: switch to polar coordinates
With , , we have and the area element becomes (a small piece of ring with radius , thickness and angle has area ). The whole plane is covered with from 0 to and from 0 to :
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 we need.
Step 4: the integral that now works
That is the derivative (up to the sign) of the exponent: . So:
And the integral in of a constant 1 is the length of the interval:
We take the positive root because is the integral of a positive function.
Step 5: back to the normal
With step 1:
Forgetting the in when switching to polar coordinates. Without it, the integral is impossible again and you get stuck. The area of a small piece of ring grows with its radius: that is the .
Result for the cheat sheet. , and in general .
Check you’ve got it: what is , and why isn’t it 1?
It’s . The denominator of the exponent is , so and : it’s the filling machine’s bell, but without the constant. By the general result for the cheat sheet, the area under is . It isn’t 1 because it’s missing the division by , 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 . 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 ), 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 , and divides it by : 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: is plenty.
Proof 2: standardising both ways (theorem 5)
What we want to prove
The two parts of theorem 5 in the notes:
- If and , with , then .
- If and , then .
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 . And part 1, , 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 with a formula, but you do not need to: rule 5 says its derivative is .
Part 1: from to
takes values on the whole line (because does too). For every real :
We subtract from both sides and divide by . Since , the inequality does not flip:
We differentiate with respect to using rule 5 (the derivative of is ):
Where the last step comes from: is the standard density evaluated at , and when you square it, . With the in front you get the in the denominator.
It is the density of an . And that is why is the way to build any normal from the standard one.
Part 2: from to
The same, but backwards. For every real :
Multiplying by does not flip it either. We differentiate (the derivative of is ):
The s cancel and the disappears inside the square: what is left is the density of the .
In the drawing, the two parts are the same path travelled in opposite directions: subtracting shifts the bell to 0 and dividing by narrows it (or widens it) to . The areas are preserved all along the way.
When solving inside the probability, forgetting the factor (or ) 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. ; ; .
Check you’ve got it: if in part 1 we had , for example , what would change in the calculation and what distribution would you get?
Dividing by a negative number flips the inequality: . When you differentiate, the minus sign in front and the from the chain rule cancel out: . Since the standard density is even, the sign of the argument doesn’t matter: you get again. The standard deviation is , 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 :
Why it matters. Up to here, and 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 , by definition:
The two exponentials have been joined: . Now, by rule 4, :
The factor comes outside because it does not depend on (rule 1). What is left inside is the density of an : it integrates to 1 by proof 1. So:
The drawing shows what completing the square does: multiplying the bell by deforms it, but the result is a bell again, shifted to and taller. Its area is , and that is the mgf.
Why complete the square
Step 1 fits in two lines, but it does six things. The same calculation, slowly:
| Step | What’s done | Why |
|---|---|---|
| 1 | When you multiply exponentials, the exponents add up | |
| 2 | You take out so that stands alone, as in the bell | |
| 3 | isn’t a square; adding and subtracting makes it one (rule 4) | |
| 4 | The is distributed: the changes sign | |
| 5 | comes out of the integral | It doesn’t depend on : it’s a constant (rule 1) |
| 6 | It’s the density of an : it integrates to 1 (proof 1) |
The underlying idea: you don’t know how to integrate 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):
The second derivative is that of a product: . Therefore .
Step 3: the mgf of any normal
By proof 2, . By rule 6, with and :
The step that gets skipped: is the mgf of evaluated at the point instead of at . You replace with in , and .
Here is the sign from the anecdote: with you would have got . The check: at every mgf equals 1, and has to be the mean, which must be and not .
Step 4: the mean and the variance, two ways
With the mgf. Call , so , with and :
Without the mgf. With and rule 1:
Writing saves a lot of work: the derivative of is , and the second, . At , . The notes differentiate the product term by term and get four terms; the result is the same.
also comes out without differentiating: 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 and giving it as the variance. is the second moment; the variance still needs subtracted. With the filling machine, the difference is between 36 and more than a million.
Result for the cheat sheet. : for every ; , , .
Check you’ve got it: if you’re told a variable has mgf , what distribution does it have?
Compare it with the form term by term. The coefficient of is the mean: . The coefficient of is half the variance: , so and . By the uniqueness of the mgf, it’s , the filling machine. The typical mistake is reading the 18 as the variance and giving .
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 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 :
- The density is symmetric about : for every . In the standard normal, is an even function.
- The median is .
- The mode is .
- The inflection points are and .
Why it matters. These four properties are behind every “by symmetry” in the exam. Symmetry gives , which is why tables only list positive ; the inflection points give you a way to read off a graph.
Symmetry
We substitute into the formula:
They are equal because . In the standard normal () this says : the density is even.
The median
In the standard normal, by rule 3 (the density is even):
So : the median of is 0. For , the median is the with . Standardising (proof 2):
The middle step uses that is strictly increasing, so the only point where it equals is 0.
The mode
The mode is the maximum of . Since the logarithm is increasing, and have their maximum at the same place, and is much easier to differentiate (the trick from topic 4):
It is a maximum because the second derivative of is . For the filling machine, the most frequent weight is 1010 g, the mean.
The inflection points
Now we do have to differentiate twice. The first time, by the chain rule:
Where it comes from: is a constant times , with , and the derivative of is . Since , itself shows up again, multiplied.
The second, differentiating that product:
Since , the sign of is that of the bracket: negative if (the curve bends down) and positive if (it bends up). It changes sign exactly at
In the drawing of the filling machine: between 1004 and 1016 the curve is concave (, violet zone) and outside it is convex (, coral zone). The inflection points are the way to see on the graph without any calculation.
In , differentiating as if were a constant. It is a product of two functions of : you get two terms, and the second uses , which you already had.
Result for the cheat sheet. Mean = median = mode = ; inflection points at ; .
Check you’ve got it: for the filling machine, . Without using R, what is ?
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: . It’s 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 and negative inside, as the bracket says.
Proof 5: aX + b is normal
What we want to prove
If and , are real numbers:
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 , and this proof guarantees you don’t have to work out the distribution again: it’s still normal. And proof 6 uses it with (the difference) and with (the mean).
Where we start
From rule 6: the mgf of is written in terms of that of , and if it has the form of the mgf of a normal, it is a normal (by uniqueness).
Step by step
The comes out of the expectation because it is a constant (rule 1). We substitute the normal mgf at the point :
How it’s grouped: and . The is added to the exponent, and the two terms in are combined: .
It has the form with and . By the uniqueness of the mgf (rule 6), is normal with mean and standard deviation .
Writing the standard deviation as . If is negative (for example, ), would be negative, and a standard deviation never is. What changes sign is the mean; the spread is .
The filling machine in kilos and the gofio “given away”
With , : , the weight in kilos. With , : , the grams given away (negative if the packet falls short). And , the same probability as always: changing scale does not change the events.
Result for the cheat sheet. . With and you get standardisation.
Check you’ve got it: what distribution does have, how much each packet falls short of the mean?
It’s with and . The mean is and the standard deviation, . So . 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 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 and are independent:
And, in general, if are independent and , their sum is and their mean .
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 . This last result, , 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:
When multiplying exponentials the exponents add, and the terms in and are grouped. It is the mgf of a normal with mean and variance . By uniqueness, done.
The difference
. By proof 5 with , : , and it is still independent of . We apply the sum:
The variance of is : that is why when subtracting, the variances also add.
The two machines in the drawing: , . The standard deviation of the difference is the hypotenuse of a right triangle with those legs, . Neither (which would assume the errors always go together) nor (which would assume they cancel out).
Many at once, and the mean
With independent , applying the sum times (or multiplying equal mgfs):
And the mean is the sum multiplied by (proof 5):
Where the roots come from: the sum of has variance , so its standard deviation is . When you divide by , since , you get .
The box of 12 packets: . The mean of 9 packets: .
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. independent and normal: . independent : sum , mean .
Check you’ve got it: why does the box of 12 packets have standard deviation 20.78 and not ?
Because 72 would be the standard deviation of , a single packet multiplied by 12 (proof 5 with ): 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: , and .
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.
- Let and . Prove that , which therefore does not depend on or , and find with R the 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: . Dividing by (the direction does not change) gives the standardised (proof 2):
By symmetry (proof 4), , leaving . It only depends on . For it to equal 0.5: , and qnorm(0.75) gives 0.6745. For the filling machine: half of the packets are less than g from 1010, between 1005.95 and 1014.05 g. That is why is sometimes called the “probable error”.
- Using the mgf of the standard normal, , compute and . Deduce that, for any normal, .
Show the solution to exercise 2
Instead of differentiating four times, expand it as a series, which is the mgf trick from topic 3: with :
On the other hand, . Comparing coefficients: there is no term, so (also by rule 3: times an even density is odd). The coefficient is , so . For : and . Divided by , 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.
- Let and (the lognormal distribution). Without integrating, compute . Apply it to and compare it with .
Show the solution to exercise 3
: the mgf evaluated at . With the formula from theorem 6:
With , : , while . The mean of the exponential is not the exponential of the mean: the term appears because 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… | Use | Watch out for… |
|---|---|---|
| The density integrating to 1, or an integral with | The Gaussian integral and a change of variable (proof 1) | The of polar coordinates |
| The distribution of or of | 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 normal | Completing the square, or (proof 3) | is not the variance |
| The median, mode, symmetry or inflection | Evenness, and (proof 4) | is the derivative of a product |
| The distribution of | The mgf and its uniqueness (proof 5) | , not |
| The distribution of a sum, difference or mean | Product of mgfs of independents (proof 6) | Saying they are independent |
| A higher moment, | The mgf series (Prove it yourself, 2) | Dividing by |
| The mgf at (Prove it yourself, 3) | It is not |
Common mistakes when proving
- Solving the standardisation the wrong way. . Check with (you get the mean) and with (one deviation above).
- Flipping the inequality for no reason. Dividing by keeps the direction; it only flips when multiplying by a negative number, as in .
- Forgetting the of polar coordinates in the Gaussian integral, or the of the change of variable.
- Mixing up the second moment with the variance: .
- Concluding that something is normal because it “looks like it”. The proof ends when the mgf has exactly the form 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:
- In the first line, the two equal numbers: 2.506628. It is the of the constant.
- Change the 6 in
rnormto 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. - In block 3, change 0.05 to 0.1: the formula and the integral still match, even though the number is huge.
- 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.
- Add
hist(z, freq = FALSE); curve(dnorm(x), add = TRUE)and look in Plots at how the standard bell fits the standardised packets.
Summary
| Result | Formula | How it is proved |
|---|---|---|
| Gaussian integral | in polar coordinates | |
| Standardising | , | of the new one, then differentiate |
| mgf | Completing the square | |
| Moments | , | Differentiating the mgf, or linearity |
| Shape | Mean = median = mode = ; inflection at | Evenness, , |
| Scale | mgf and uniqueness | |
| Sum and difference | Product of mgfs | |
| Mean of | Sum times |
Three ideas to take away:
- Almost everything comes from two pieces: 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.
- 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.
- Variances rule: they are multiplied by 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 →



