The normal distribution — theory with a gofio filling machine, the bell curve, standardising and quantiles (and the 39 % that wasn’t)
At a gofio mill in the north of the island I took my phone out to show off and told the manager that 39 % of his packets weighed less than a kilo. He had told us that his filling machine fills one-kilo packets with a mean of 1010 grams and a variance of 36, and I had typed pnorm(1000, 1010, 36), which gave 0.39. He looked at me the way you look at someone who has just called your boss a thief. The mistake was mine: R wants the standard deviation, not the variance. With pnorm(1000, 1010, 6) you get 0.048, less than 5 %. One wrong number and the conclusion goes from “the machine is fine” to “the machine is a scam”.
This topic is about the normal distribution, the bell curve: the one you will use most in ME1, in ME2 and in everything that comes after, because sums and averages of almost anything end up looking like it. We carry on from continuous random variables: a density, its distribution function, its moments and R’s d, p, q and r functions. The difference is that the normal has no distribution function you can write as a formula, so here you learn to standardise, to read quantiles and to combine normals. All of it with the filling machine of a gofio cooperative (gofio is the toasted grain flour of the Canary Islands), with made-up but realistic data. The proofs, step by step, are in the normal distribution proofs.
Table of Contents
Before you start. For this topic you need topic 4, continuous random variables: that in a continuous variable probability is an area under the density, that the distribution function is the area up to , that a quantile is the value that leaves a given probability to its left, and R’s d, p, q and r functions. You need no new calculus: nothing is integrated by hand here. The topic has four big ideas, in this order: what the bell looks like and what its two parameters do (the density); why its area has no formula and how you ask R or the table for it (pnorm and standardising, with symmetry for negative tails); the way back, from an area to a weight (qnorm); and what happens when you change units, add or subtract normals. We use the same example all the way through: the gofio filling machine, . If you get lost, draw the bell, mark the weight and shade the area you are asked for: almost every mistake in this topic shows up in that drawing.
The bell that shows up everywhere
Why so many things are normal
Think about what decides how much gofio falls into a packet: the moisture of the grain that day, how compact it comes out of the hopper, a vibration of the belt, the exact instant the gate closes, the temperature of the motor… Each one pushes a few grams up or down, and none of them dominates the rest. When a result is the sum of many small, independent effects, its distribution gets close to a symmetric bell. That is what the central limit theorem says, which you will see in topic 7, and it is why the normal appears in the weight of packets, in people’s height, in the measurement errors of a sensor, in the marks of a large exam or in the time a task repeated a thousand times takes.
The normal is also called the Gaussian distribution or Gaussian bell curve, after Carl Friedrich Gauss, who used it for the errors of astronomical measurements at the start of the 19th century.
The example for the whole topic
The cooperative has a machine that fills 1 kg packets of gofio. It does not always put in the same amount: if you weigh many packets, most are close to 1010 g, a few go to 995 or 1025 and almost none go beyond that. We call the weight of a packet, in grams, and the model we will use is
that is, a mean of 1010 grams and a standard deviation of 6 grams. The label says “1 kg”, so the question the cooperative cares about is how many packets weigh less than 1000 g. Throughout the topic we will also adjust the machine, put the packets into boxes of 12 and compare two machines.
Before the formula: what shape the bell has to have
Before seeing the density with all its symbols, let’s work out what it has to satisfy from what we already know about the filling machine. The question is simple: if you weigh lots of packets, how are the weights spread out?
- There is a center. Most packets land near 1010 g, so the density has to peak there.
- The side doesn’t matter. The machine has no preference for overfilling or underfilling: a 1004 g packet is as likely as a 1016 g one. The curve has to be symmetric about 1010.
- Far away drops fast. There are few packets of 995 g or 1025 g, and almost none of 1040 g. It is not enough for the curve to go down: it has to go down faster and faster.
- Distance is measured in standard deviations. “Far” depends on the machine. 12 grams is a lot for a precise machine and not much for a shaky one. The natural thing is to count distance in standard deviations: 12 g with is 2 standard deviations.
- The total area is 1, as for any density.
The function that does all of that is , where is the distance from the center counted in standard deviations. Look at how the height, compared with the peak, falls as you move away from the center of the filling machine:
| Weight (g) | Distance in standard deviations, | Relative height, | Why |
|---|---|---|---|
| 1010 | 0 | 1 | It is the peak: |
| 1016 or 1004 | 1 | 0.61 | The square makes and give the same value: that is the symmetry |
| 1022 or 998 | 2 | 0.14 | Twice as far does not give half the height (0.30), but much less: the exponent is |
| 1028 or 992 | 3 | 0.01 | With in the exponent there is almost nothing left |
| 1034 or 986 | 4 | 0.0003 | That is why a packet 4 standard deviations away makes you suspect the machine |
All that is left is making the total area 1. The curve has area (it is the Gaussian integral), and going from to grams stretches it sideways by . So you have to divide by . With , what comes out is the normal density coming up next. It is not a formula that falls from the sky: it is “a bell that falls with the square of the distance in standard deviations, adjusted so that the area is 1”.
The normal density
What it is
A continuous random variable , taking values on the whole real line, follows a normal distribution with parameters and , written , if its density function is for every real , with real and . The case , is the standard normal.
Look at the formula piece by piece, because each piece explains something in the picture:
- measures how far is from the center. Because it is squared, moving away to the left is the same as moving away to the right: hence the symmetry.
- The minus sign and the exponential make the density smaller the further away you go, and very fast: going twice as far does not halve the height, it divides it by a huge amount.
- Dividing by turns the distance into “number of standard deviations”. Being 12 grams from the center with is being 2 deviations away; with it would be 4, and that is already very far.
- is the constant that makes the total area 1. That appears is not obvious: it is the Gaussian integral, proved in proof 1.
The ME1 notes and R write , with the standard deviation. Many books (and other courses) write , with the variance. Before using a figure, check what you are being given: if the statement says “variance 36”, R gets a 6. It is exactly the 39 % mistake from the beginning.
The shape of the bell
Look at the drawing of the filling machine, . Everything important can be read from it:
- It is symmetric about . The density at 1004 is the same as at 1016, because both are 6 g from the center.
- Mean, median and mode coincide at . The peak is at 1010 (mode), half the area lies on each side of 1010 (median) and the balance point is also 1010 (mean).
- The inflection points are at and , at 1004 and 1016: there the curve stops “bending down” and starts “bending up”. It is a way to see in the picture.
- The maximum height is , which with is 0.0665. It is not a probability: it is a density, just like in the previous topic.
- It never touches zero. Mathematically, a 950 g packet has a positive density, even if it is a number with many zeros. In practice, beyond 3 or 4 deviations there is hardly anything.
That the normal allows any real value, negative ones too, does not mean a packet can weigh −20 g. The model is an approximation: for the gofio weight the probability of a negative value is so small (it is 168 deviations from the center) that it does not matter. Where it does matter, you will see further down that the normal does not work.
How and change it
The two parameters do different things, and it is worth seeing in R. We compare the cooperative’s machine with a new machine, , which puts in a bit less but is more precise:
x <- seq(980, 1040, length = 300) # grid of weights, in grams
par(mfrow = c(1, 2)) # two plots, side by side
# Densities: the old one (violet) and the new one (coral)
plot(x, dnorm(x, 1010, 6), type = "l", lwd = 2, col = "purple",
ylim = c(0, 0.11), xlab = "grams", ylab = "f(x)")
lines(x, dnorm(x, 1004, 4), lwd = 2, col = "tomato")
# Distribution functions of both
plot(x, pnorm(x, 1010, 6), type = "l", lwd = 2, col = "purple",
xlab = "grams", ylab = "F(x)")
lines(x, pnorm(x, 1004, 4), lwd = 2, col = "tomato")
c(dnorm(1010, 1010, 6), dnorm(1004, 1004, 4)) # heights of the peaks
Output:
[1] 0.06649038 0.09973557
How to read it
[1] 0.06649038 0.09973557are the heights of the two peaks: and . The new one has a taller bell because it is narrower: the area under each curve is still 1, so if it shrinks sideways it has to grow upwards.- In the left-hand plot, moves the bell along the axis without changing its shape: the coral one is 6 grams further left.
- widens or narrows it. The violet one () is lower and wider; the coral one (), taller and tighter.
- On the right, the two distribution functions are S curves rising from 0 to 1. Each crosses height 0.5 exactly at its mean (1004 and 1010), because in the normal the mean is the median. The coral one is steeper: since the new machine is more precise, probability builds up over a shorter stretch.
- The two S curves cross at 992 g (where ): to the left of that point, the new one has more accumulated probability. We will use this when comparing the two machines.
The distribution function
No formula: it is computed
The distribution function is, as always, the area of the density up to :
The surprise is that this integral has no antiderivative you can write with elementary functions (polynomials, exponentials, logarithms, sines…). It is not that it is hard: it has been proved that none exists. That is why is evaluated numerically, and for the standard normal it has its own name:
People used to look it up in a printed table of ; in ME1 you use pnorm. In the exam you are not asked to integrate the normal; you are asked to know which area to compute and how to ask R for it.
The probability that a packet weighs less than a kilo
pnorm(1000, mean = 1010, sd = 6) # P(X <= 1000) 1 - pnorm(1000, 1010, 6) # P(X > 1000) pnorm(1000, 1010, 6, lower.tail = FALSE) # the same, without subtracting pnorm(1020, 1010, 6) - pnorm(1000, 1010, 6) # P(1000 < X < 1020)
Output:
[1] 0.04779035 [1] 0.9522096 [1] 0.9522096 [1] 0.9044193
How to read it
0.04779035: 4.78 % of the packets weigh less than 1 kg. With two decimals, as in the exam, 0.05. It is the area of the left tail you see in the bell drawing.0.9522096and again0.9522096: what is left up to 1. Both lines say the same;lower.tail = FALSEasks directly for the right tail, and for very small tails it is more accurate than subtracting.0.9044193: 90.4 % of the packets weigh between 1 and 1.02 kg. The probability of an interval is the of the right end minus that of the left end, the same rule as in the previous topic.- For a continuous variable and are the same: , so . In the discrete variables of topic 3 that was not the case, and it is a source of mistakes when you switch topics.
Writing pnorm(1000, 1010, 6) when you are asked about weighing more than 1000. pnorm always gives the area on the left. Before typing, draw the bell and shade what you are asked for: if it is the right tail, put 1 - in front.
Standardising: the standard normal
The idea
All normals are the same bell, stretched and shifted. If you subtract the mean from a weight and divide by the standard deviation, what is left is how many standard deviations it is above or below the center. That is standardising:
And the way back, which matters just as much:
Both results are theorem 5 in the notes and are proved in proof 2.
In the drawing, the top ruler is in grams and the bottom one in . A 1000 g packet is standard deviations away: a bit more than one and a half below the center. Areas do not change when you move from one ruler to the other:
z <- (1000 - 1010) / 6 # how many standard deviations below z pnorm(z) # Phi(z): standard normal, no need for 0 and 1 pnorm(1000, 1010, 6) # without standardising: the same number
Output:
[1] -1.666667 [1] 0.04779035 [1] 0.04779035
How to read it
-1.666667is the of the one-kilo packet. The sign tells you the side: negative, below the mean.- The last two lines give
0.04779035. Standardising does not change the probability, only the ruler it is measured with. Whenpnormgets a single number, it uses the standard normal (its defaults aremean = 0andsd = 1). - In the exam, if you have the data and R, you can compute without standardising. But proofs and paper questions are done by standardising, and in topics 8 to 11 almost everything starts with a .
Going back from to with the wrong algebra. If , then , not nor . Quick check: with you must get the mean, and with a negative , something below it.
Standardising, step by step
The formula above does four things in one line. Here they are separately, with the one-kilo packet, because it is the move you will repeat in almost every exercise of the topic:
| Step | Calculation | Why |
|---|---|---|
| 1 | It is what is being asked: the proportion of packets under one kilo | |
| 2 | Subtracting the same thing (the mean) from both sides of an inequality does not change it: now we measure from the center | |
| 3 | Dividing by a positive number () does not flip it either: now we measure in standard deviations | |
| 4 | The left-hand side is , which is by theorem 5. On the right, rounded to two decimals | |
| 5 | It is an area to the left in the standard normal: pnorm(-1.67), or the table with the symmetry in the next section |
Why 0.0475 and not the 0.04779 from before? Because was rounded. pnorm(z) with gives 0.0478, and with it gives 0.0475. With two decimals, both are 0.05. The underlying idea is that the inequality is transformed in the same way on both sides, so the event is the same and so is the probability. The only thing that changes is the ruler you measure with.
The sign of already gives you half the answer. If is negative, the weight is below the mean and has to come out below 0.5. With , a probability of 0.95 would be the wrong tail.
Symmetry saves calculations
Since the standard normal is symmetric about 0:
Why it holds, in words: the standard bell is a mirror with the glass at 0. The tail to the left of is the exact reflection of the tail to the right of , and that right tail is everything (1) minus what lies to the left of . With that idea you get the four cases that come up in the exercises, with :
| You are asked for | You turn it into | Why | With |
|---|---|---|---|
| Mirror: the left tail of is the right tail of | 0.0475 | ||
| Mirror again: what lies to the right of is what lies to the left of | 0.9525 | ||
| It is the complement of : everything minus the left | 0.0475 | ||
| The middle is 1 minus two equal tails: | 0.9050 |
Writing , or for the left tail. A probability is never negative, and is the tail to the right of , not the left one. Quick check: if is negative, has to come out below 0.5.
The area to the left of is the same as to the right of . And for absolute values:
With the filling machine: what proportion of packets is less than 5 grams away from the mean?
2 * pnorm(5 / 6) - 1 # with the formula pnorm(1015, 1010, 6) - pnorm(1005, 1010, 6) # with the interval
Output:
[1] 0.5953432 [1] 0.5953432
Both give 0.5953: a little under 60 % of the packets are less than 5 grams from 1010. The absolute value is always solved the same way: is the interval .
“Shifted” absolute values, like when , are not symmetric about the mean. Do not use the formula: write the interval and subtract with pnorm.
If you are given the table instead of R
In ME1 you work with pnorm, but it is worth knowing how to read the table: it appears in books and in many old exams, and it is the best way to understand what pnorm returns. The usual table gives only for and with two decimals: the row gives the units and the first decimal digit, and the column gives the second. With the one-kilo packet:
- Round to two decimals. becomes .
- Drop the sign. The table has no negatives: you look up and then use symmetry.
- Row and column. Row 1.6 and column 0.07: it says 0.9525. That is , the area to the left of .
- Put the sign back. .
It is the same as pnorm(-1.67). Think of pnorm as an infinite table, with every decimal of : that is why pnorm(1000, 1010, 6), which uses the unrounded , gives 0.0478 and not 0.0475. With two decimals both give 0.05, which is what counts in the exam.
The same goes for the packets less than 5 grams from the mean. ; row 0.8 and column 0.03 give , and . R gave 0.5953 because it uses : once again, the difference is only the rounding of .
When you use the table, write with two decimals before looking it up and say in your answer that you rounded it. If you compare with pnorm and see a difference in the third decimal, that is why; it is not a mistake.
Check you’ve got it: using only the table, what proportion of packets weigh more than 1020 g?
About 0.05. First you standardise: . You are asked for the right tail, so . It comes out the same as for the packets under 1000 g, and that is no coincidence: 1000 and 1020 are both 10 g from the mean, one on each side, and the two tails are reflections of each other. With pnorm, 1 – pnorm(1020, 1010, 6) gives 0.0478; with two decimals, 0.05 both.
The 68-95-99.7 rule
There are three numbers worth knowing by heart, because they hold for any normal:
With the filling machine, in the drawing: 68 % of the packets weigh between 1004 and 1016 g, 95 % between 998 and 1022 g, and 99.7 % between 992 and 1028 g. A 985 g packet is more than 4 deviations away: if one turns up, the sensible thing is to suspect the machine before bad luck.
k <- 1:3 round(pnorm(k) - pnorm(-k), 4) # P(|Z| <= k) for k = 1, 2, 3
Output:
[1] 0.6827 0.9545 0.9973
0.6827 0.9545 0.9973: these are the exact values. They do not depend on or , because standardising turns every normal into the same . It is the same empirical rule you saw in descriptive statistics for bell-shaped data: there it was an approximate rule for data; here it is an exact property of the model.
Use it to sanity-check any pnorm result. If you get that 30 % of the packets are more than 3 deviations from the center, you have typed something wrong (probably the variance where the standard deviation should go).
Check you’ve got it: without calculating anything, what proportion of packets weigh more than 1022 g?
Roughly 2.5 %. 1022 is : it is two standard deviations above the mean. Between and lies 95 %, so 5 % lies outside. That 5 % is split into two equal tails by symmetry, and the upper one gets half: 2.5 %. The exact value is 1 – pnorm(2) = 0.0228, 0.02 with two decimals; it comes out a little lower because the rule rounds 0.9545 to 0.95.
Quantiles: qnorm
From the area to the value
pnorm goes from a value to an area; qnorm goes the other way: you give it a probability and it returns the value that leaves that probability to its left.
where is the standard quantile. These five quantiles come back again and again (in the confidence intervals of topic 11, above all):
round(qnorm(c(0.90, 0.95, 0.975, 0.99, 0.995)), 4)
Output:
[1] 1.2816 1.6449 1.9600 2.3263 2.5758
| 0.90 | 0.95 | 0.975 | 0.99 | 0.995 | |
|---|---|---|---|---|---|
| 1.2816 | 1.6449 | 1.9600 | 2.3263 | 2.5758 |
The 1.96 is the “2” of the 68-95-99.7 rule, sharpened: between and lies exactly 95 %.
“More than” becomes “less than”
The typical statement is: “what weight do only 10 % of the packets exceed?”. You are given an area on the right, and qnorm works with areas on the left:
qnorm(0.90, 1010, 6) # what only 10 % exceed 1010 + qnorm(0.90) * 6 # the same, standardising backwards qnorm(0.10, 1010, 6) # what it is NOT: leaves 10 % on the left qnorm(0.10, 1010, 6, lower.tail = FALSE) # this also works
Output:
[1] 1017.689 [1] 1017.689 [1] 1002.311 [1] 1017.689
How to read it
1017.689: only 10 % of the packets weigh more than 1017.69 g. With two decimals, 1017.69.- The second line gives the same: it is . It is standardising in reverse.
1002.311is the 0.10 quantile: the weight below which 10 % lie. It is the same distance from the center (7.69 g) but on the other side: symmetry again.lower.tail = FALSEtellsqnormthat the probability you give it is the one on the right. It gives 1017.689, like the first line.
Answering qnorm(0.10, 1010, 6) to “what only 10 % exceed”. You get a weight below the mean, and the question is about the heaviest packets. If the result lands on the wrong side of the center, check the tail.
A quantile, step by step
Quantile questions are pnorm in reverse, and that is why you solve them in the opposite order: first the area, then , and finally the grams. With “what weight do only 10 % of the packets exceed?”:
| Step | What you do | Why |
|---|---|---|
| 1 | Draw the bell and shade the right-hand 10 % | The question is about the heaviest packets: it is the right tail |
| 2 | Turn it into the left: | qnorm and the table work with the area to the left |
| 3 | Find | In R, qnorm(0.90). With the table, you look for 0.90 inside the table: it lies between and , closer to 1.28 |
| 4 | Undo the standardisation: | From you solve |
| 5 | Check: 1017.69 is above 1010, and pnorm(1017.69, 1010, 6) gives 0.90 | A quantile of the right tail has to fall to the right of the center |
For left tails, symmetry gives a shortcut: . The lightest 5 %, for example, lies below , which is the 1.6449 from the quantile table with the sign changed. In grams, .
Check you’ve got it: what weight do 95 % of the packets exceed?
1000.13 g. “95 % exceed it” leaves 95 % to the right, so 5 % is left to the left: it is the 0.05 quantile, not the 0.95 one. With , . In R, qnorm(0.05, 1010, 6). Check: it falls below the mean, as it must if almost every packet exceeds it. If you got qnorm(0.95, 1010, 6) = 1019.87, that is the weight that only 5 % exceed.
Adjusting the machine
Now the question the cooperative really asks: where should the mean be set so that only 1 % of the packets weigh less than a kilo, without changing the machine’s precision ()? We want , with and unknown. Standardising:
mu <- 1000 - qnorm(0.01) * 6 # solving for mu mu pnorm(1000, mu, 6) # check: it must give 0.01
Output:
[1] 1013.958 [1] 0.01
1013.958 and 0.01: with the mean at 1013.96 g, one packet in a hundred weighs less than 1 kg. Watch the sign: is negative, so subtracting it adds 13.96 grams. Every packet carries almost 14 grams of gofio “given away” to meet the label; the other way to comply is to improve the machine (lower ), which is what the new machine does.
Put into words: 1000 g has to sit exactly at the point that leaves 1 % to its left. In any normal, that point is 2.33 standard deviations below the mean. So the mean has to be 2.33 standard deviations above 1000, that is, grams above. The whole calculation above is that sentence written in symbols.
Check you’ve got it: with the new filling machine (), where do you have to set the mean so that only 1 % of the packets weigh less than 1 kg?
At 1009.31 g. The sentence is the same: the mean has to be 2.3263 standard deviations above 1000, but now each standard deviation is 4 g. So ; in R, 1000 – qnorm(0.01) * 4. You give away 9.31 g per packet instead of 13.96: about 4.65 g less per packet, just from having a more precise machine.
Mean, variance and mgf
The parameters of the normal are its mean and its standard deviation, and that is not a coincidence of notation:
It is theorem 6 in the notes. The mgf comes from “completing the square” in the integral and, differentiating it at , the mean and the variance appear; they can also be obtained without differentiating, using and linearity. Both routes are in proof 3.
The normal mgf exists for every real , unlike that of the exponential or the gamma in the previous topic, which only existed for . And since the mgf characterises the distribution, it is the tool for proving that a combination of normals is normal: if its mgf has the form , it is an .
Linear combinations of normals
This is the part that pays off most in the exam, because it lets you go from a packet to a box, from grams to kilos or from one machine to the difference between two.
Changing scale: aX + b
A change of units takes nobody out of the normal. If you convert the weight to kilos, . If you subtract the 1000 grams on the label to keep only the “gift”, : the standard deviation does not change when you add a constant, because shifting does not widen. It is proved with the mgf in proof 5.
Multiplying the variance by instead of , or the standard deviation by . The rule is: the mean times , the variance times , the standard deviation times . In kilos: and .
Adding independent normals
If are independent normals, , then
The means add and the variances add, not the standard deviations. A box with 12 packets from the machine weighs
In the drawing, the box has its bell 12 times further right but only times wider. The errors of the packets partly cancel out: one goes over, another falls short. If you added the standard deviations (), you would be assuming that all the packets get it wrong at the same time and in the same direction, and that is not independence.
Subtracting independent normals
The case people get wrong most: the difference. We compare a packet from the old machine, , with one from the new machine, :
When subtracting, the variances also add: . The difference is more uncertain than each packet on its own. What is the probability that the old machine’s packet weighs more than the new one’s?
mD <- 1010 - 1004; sD <- sqrt(6^2 + 4^2) c(mD, sD) 1 - pnorm(0, mD, sD) # P(XA - XB > 0) set.seed(2026) # checking by simulation mean(rnorm(1e5, 1010, 6) > rnorm(1e5, 1004, 4))
Output:
[1] 6.000000 7.211103 [1] 0.7973097 [1] 0.79734
How to read it
6.000000 7.211103: the difference has mean 6 g and standard deviation 7.21 g, more than either machine.0.7973097: in 79.73 % of the pairs, the old machine’s packet is heavier. It is not 100 %, even though its mean is 6 g higher: the bells overlap.- The simulation gives
0.79734, practically the same. A hundred thousand pairs of simulated packets withrnormand the proportion in which the old one wins: that is how you check a paper result with R. With another seed it would differ in the fifth decimal: that is the randomness of simulating.
Computing the standard deviation of the difference as , or as . Subtracting the variables does not subtract their uncertainty: it adds it.
The difference, by hand
Without R, the same question is solved with everything in the topic in four steps:
| Step | Calculation | Why |
|---|---|---|
| 1 | Comparing two variables means looking at the sign of their difference, and we do know the distribution of the difference | |
| 2 | The means subtract; the variances add: | |
| 3 | Standardise: subtract the mean and divide by the standard deviation on both sides | |
| 4 | Symmetry: what lies to the right of is what lies to the left of |
With two decimals, 0.80, the same as pnorm’s 0.7973: the difference in the third decimal is again the rounding of , which is really . Notice that almost every idea in the topic has come up together here: combining normals, standardising and using symmetry for a negative tail.
The mean of n packets
A special case you will see in every remaining topic: if are independent and , their mean is
It is the sum (, ) multiplied by . The mean of 9 packets from the machine is : three times more precise than a single packet. In topic 8 this will be the distribution of the sample mean.
R’s d, p, q and r functions
The four letters as always, now with norm and the arguments mean and sd (0 and 1 by default):
| Function | What it returns | With the filling machine | Result |
|---|---|---|---|
dnorm(x, mu, sigma) | the density , a height | dnorm(1010, 1010, 6) | 0.0665 |
pnorm(x, mu, sigma) | , an area | pnorm(1000, 1010, 6) | 0.0478 |
qnorm(p, mu, sigma) | the value leaving to its left | qnorm(0.9, 1010, 6) | 1017.69 |
rnorm(n, mu, sigma) | simulated values | rnorm(5, 1010, 6) | five random weights |
In the drawing, all four on the same bell. Two details that save trouble:
- The third argument is
sd, the standard deviation. If you write the arguments by name (mean = 1010, sd = 6), you cannot get the order wrong and it is clear what each number is. pnormandqnormare inverses:qnorm(pnorm(1000, 1010, 6), 1010, 6)returns 1000.
When to use the normal (and when not)
The normal is a good model when the variable is the sum of many small effects, is symmetric and has no limit nearby. Before using it with data, draw the histogram and the quantile-quantile plot (qqnorm), which you will see in the practice.
| The variable | Normal? | Why |
|---|---|---|
| The weight of a gofio packet | Yes | many small effects, symmetric, no limit nearby |
| The mean weight of 9 packets | Yes | the mean of normals is normal (and by the CLT, almost always) |
| The time until the next customer arrives | No | skewed, starts at 0: exponential (topic 4) |
| The proportion of a dish that comes out hot | No | bounded between 0 and 1: beta (topic 4) |
| The number of faulty packets in a box | No | discrete: binomial (topic 3) |
| The marks of a 40-person exam, with many zeros | No | limits at 0 and at 10 and a long tail |
Data that “look” normal are not proof that they are. In ME2 you will learn to test it; in ME1 the histogram and the quantile-quantile plot are enough, as long as you can explain what you see.
What is proved in this topic
Here you have seen the results. The normal distribution proofs show, step by step, why they are true, with the same filling machine:
| Result | Proof |
|---|---|
| The normal density integrates to 1: the Gaussian integral, | Proof 1 |
| Standardising both ways: and (theorem 5) | Proof 2 |
| The mgf, the mean and the variance (theorem 6), with the mgf and without it | Proof 3 |
| Symmetry: median and mode at , inflection points at | Proof 4 |
| is normal, with the mgf | Proof 5 |
| The sum and difference of independent normals, and the mean of | Proof 6 |
Common mistakes
Putting the variance where the standard deviation goes: pnorm(1000, 1010, 36) instead of pnorm(1000, 1010, 6). It gives 0.39 instead of 0.05.
Computing a right tail without the 1 -. pnorm always returns the area on the left.
Answering with qnorm(0.1) to “the value only 10 % exceed”. What leaves 10 % on the right leaves 90 % on the left: qnorm(0.9).
Adding standard deviations when adding normals, or subtracting them when subtracting. What adds, always, is the variances (and only if the variables are independent).
Reading dnorm(1010, 1010, 6) = 0.0665 as “6.65 % of the packets weigh 1010 g”. It is a height; the probability of an exact value is 0.
Try it in the R playground
Open the site’s R playground (or RStudio) and paste this script. It brings together the bell, the tail of light packets, adjusting the machine and the box of 12:
# The filling machine: X ~ N(1010, 6), in grams curve(dnorm(x, 1010, 6), from = 985, to = 1035, lwd = 2, ylab = "f(x)") abline(v = c(1004, 1010, 1016), lty = 2) # mu - sigma, mu, mu + sigma pnorm(1000, 1010, 6) # packets under 1 kg qnorm(0.90, 1010, 6) # what only 10 % exceed 1000 - qnorm(0.01) * 6 # mean for 1 % below # A box of 12 independent packets box <- replicate(10000, sum(rnorm(12, 1010, 6))) c(mean(box), sd(box), sqrt(12) * 6) # the box sd is 6 * sqrt(12) hist(box, freq = FALSE, breaks = 40) curve(dnorm(x, 12120, sqrt(12) * 6), add = TRUE, lwd = 2, col = "tomato")
What to look at:
- In the first plot, the three lines: the middle one goes through the peak and the other two through the points where the curve changes curvature.
- Change the 6 in
pnormto 36 and run it again: it is the 39 % from the beginning. That is how much this mistake weighs. - Change
0.01to0.001: how many more grams have to be given away so that only one packet in a thousand falls short? - In the box, compare
sd(box)withsqrt(12) * 6: almost equal. Now compare it with12 * 6, which is what adding standard deviations would give. - Type
?Normalin the console and read the arguments of the four functions in Help; notice that the third one is calledsd.
Summary
| Concept | Formula | In R |
|---|---|---|
| Density | dnorm(x, mu, sigma) | |
| Distribution function | , no closed form | pnorm(x, mu, sigma) |
| Standardise | ; | (x - mu) / sigma |
| Quantile | qnorm(p, mu, sigma) | |
| Moments | , | — |
| mgf | , for every | — |
| Change of scale | — | |
| Sum or difference of independents | means with their sign, variances always added | — |
| 68-95-99.7 rule | = 0.6827; 0.9545; 0.9973 | pnorm(k) - pnorm(-k) |
Three ideas to take away:
- All normals are the same bell: standardising turns it into the standard one and brings it back. A probability or a quantile of any normal comes down to and .
- R wants the standard deviation. Read the statement twice when you are given a variance, and draw the tail before typing
pnormorqnorm. - The variances of independents add, also when subtracting. That is why a box of 12 packets is only times more uncertain than a packet, and why the mean of narrows with .
If you want to see why all this is true, carry on with the proofs. To do it with R, with 10,000 simulated packets, data from a scale and boxes of 12, there is the normal distribution practice. And to check you have got it, the normal distribution exercises have exam-style exercises with commented solutions.
Next step: proofsThe normal distribution — step-by-step proofs with the Gaussian integral, the mgf and variances that add up (and the mean of −1010 grams)Did this article help you? Here is how you can support SergioLearns →



