The normal distribution — exam-style exercises with mills, boxes of 12 and half-kilo bags (and the 10 % that was in the wrong tail)

In a practice exam in class I was asked for “the time only 10 % of the sacks exceed” and I answered, very quickly, with qnorm(0.10, 42, 4): 36.87 minutes. That is the time only 10 % do NOT exceed, the one for the fastest sacks. The lecturer circled it in red with an arrow towards the right of the bell. What was being asked for was on the other side, at 47.13. If I had drawn the bell and shaded the tail before typing, I would have seen that my answer was below the mean when the question was about the slowest ones.

These exercises follow the format of the ME1 EC2, which starts right at the normal: one context per exercise, chained parts with their marks, calculations by hand and calculations with R. They are original, with the gofio cooperative from the normal distribution theory, and they go over what comes up most: standardising and going back, tails and quantiles, linear combinations of independent normals, a proof with the mgf and some data you have to look at before using the model. If a proof gets stuck, you have them step by step in the topic proofs.

How to use this article

  • Do the exercises with the exam in mind. In the ME1 EC2 you have 4 hours for 50 marks, with RStudio and the data open. These three exercises add up to 40 marks plus a 2.5 bonus: give them about 3 hours and 10 minutes.
  • Paper for what is proved, R for what is computed. Results with 2 decimals, as the exam asks (and small probabilities with 4, so they do not come out as 0.00). Whatever you do in R, keep it in a script: at the end of the exam you have to upload the .R file with the code for each exercise.
  • Draw the bell before every pnorm or qnorm. Half a minute with a pencil avoids the mistake in the anecdote.
  • Mark yourself with the criteria. Each solution comes with “How it is marked”, with a breakdown of the marks. It is a guide, mine: it is not the official marking scheme.
  • Finish with the cheat sheet and “For your script”. The cheat sheet only has results (it is what you can take handwritten into the exam: two sheets, both sides, in the EC2) and “For your script” is the topic’s code ready for your .R file. If you want to revise first on the computer, the R practice has the topic’s three programs with comments.

Exercise 1: the mill (10 marks)

At the cooperative’s mill, the time it takes to grind a sack of toasted maize, TT, in minutes, follows a normal distribution with mean 42 minutes and variance 16.

(a) Write the distribution of TT in R notation and compute the probability that a sack takes more than 45 minutes. (2 marks)

(b) By standardising, express P(∣T−42∣≥6)P(|T – 42| \ge 6) in terms of Φ\Phi and compute it with R. (2 marks)

(c) Compute the time that only 10 % of the sacks exceed. (2 marks)

(d) Let HH be the grinding time in hours. Give its distribution and compute P(H>0.75)P(H > 0.75). Why does it come out the same as in (a)? (2 marks)

(e) One day 5 sacks are ground, with independent times. Compute the probability that at least one takes more than 50 minutes. (2 marks)

First of all, the variance 16: the standard deviation is 4. In (e), the normal gives the probability for one sack, and “at least one out of five” belongs to another topic.

Exercise 2: boxes and filling machines (15 marks)

The cooperative’s machine fills 1 kg packets with a weight, in grams, X∼N(1010,6)X \sim N(1010, 6). The packets go 12 at a time into a cardboard box whose weight is C∼N(240,10)C \sim N(240, 10). All weights are independent.

(a) Prove, using the moment generating function, that if X1,…,XnX_1, \dots, X_n are independent with Xi∼N(μi,σi)X_i \sim N(\mu_i, \sigma_i), then X1+⋯+XnX_1 + \cdots + X_n is normal, and give its mean and standard deviation. (4 marks)

(b) Let WW be the weight of a full box (12 packets plus the cardboard). Give its distribution and compute the probability that it exceeds 12,400 g. (3 marks)

(c) An inspector weighs 9 packets and computes their mean weight, Xˉ\bar{X}. Give the distribution of Xˉ\bar{X} and the probability that it is below 1006 g. (2 marks)

(d) A second machine fills with Y∼N(1004,4)Y \sim N(1004, 4). Compute the probability that a packet from the first weighs more than one from the second, and compare the proportion of packets under 1 kg from each. (3 marks)

(e) With R, simulate 10,000 full boxes and check the mean, the standard deviation and the probability in part (b). (3 marks)

In (a), the mgf of a sum of independents is the product of the mgfs. In (b) and (d), what adds up is the variances, also when subtracting.

Exercise 3: the half-kilo bags (15 marks)

The cooperative also sells gofio in 500 g bags, filled by another machine. An inspector has weighed 40 bags (in grams):

bags <- c(511.7, 506.0, 509.2, 508.0, 508.1, 507.2, 507.0, 513.6, 506.2, 504.7,
          507.5, 511.5, 501.9, 509.8, 502.9, 509.1, 504.7, 514.6, 503.0, 505.6,
          504.8, 510.5, 504.3, 508.0, 509.8, 508.6, 503.7, 507.5, 502.9, 515.6,
          506.3, 504.8, 503.5, 505.0, 505.2, 509.9, 506.4, 506.6, 507.9, 510.8)

(a) With R, compute the mean and standard deviation of the weighings and draw their density-scale histogram with the normal with those parameters on top. (3 marks)

(b) Draw the normal quantile-quantile plot of the data and comment on whether the normal model is reasonable. (2 marks)

(c) Compare the proportion of bags under 500 g in the data with the one given by the fitted normal model. Comment on the difference. (2 marks)

(d) 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. Using the fitted model, find the interval centred on the mean that contains 90 % of the bags. (4 marks)

(e) Without changing the machine’s precision (the σ\sigma estimated in (a)), at what value should the mean be set so that only 0.5 % of the bags weigh less than 500 g? (4 marks)

In (d), write the absolute value as an interval and standardise. In (e), z0.005z_{0.005} is negative: careful with the sign when solving.

Bonus (2.5 marks)

Let Z∼N(0,1)Z \sim N(0, 1). Compute E(∣Z∣)E(|Z|) by integrating and deduce E(∣X−μ∣)E(|X – \mu|) for X∼N(μ,σ)X \sim N(\mu, \sigma). On average, how far is a packet from the machine from its mean of 1010 g?

Solutions

Exercise 1

(a) Variance 16 means standard deviation 4: T∼N(42,4)T \sim N(42, 4), and in R pnorm(…, 42, 4).

P(T>45)=1−P(T≤45)=1−Φ(45−424)=1−Φ(0.75) P(T > 45) = 1 – P(T \le 45) = 1 – \Phi\left(\frac{45 – 42}{4}\right) = 1 – \Phi(0.75)
1 - pnorm(45, 42, 4)

Output:

[1] 0.2266274

0.23: almost one sack in four takes more than 45 minutes.

(b) The absolute value is the union of the two tails: ∣T−42∣≥6  ⟺  T≤36|T – 42| \ge 6 \iff T \le 36 or T≥48T \ge 48. Standardising, T−424=Z\frac{T – 42}{4} = Z:

P(∣T−42∣≥6)=P(∣Z∣≥64)=P(Z≤−1.5)+P(Z≥1.5)=2 Φ(−1.5)=2(1−Φ(1.5)) P(|T – 42| \ge 6) = P\left(|Z| \ge \tfrac{6}{4}\right) = P(Z \le -1.5) + P(Z \ge 1.5) = 2\,\Phi(-1.5) = 2\big(1 – \Phi(1.5)\big)

The last equality is by symmetry: Φ(−z)=1−Φ(z)\Phi(-z) = 1 – \Phi(z).

The picture behind it. Two shaded tails, from 36 downwards and from 48 upwards, each 1.5 standard deviations from the mean: by symmetry they weigh the same, so it is enough to compute one and multiply by 2. The obvious route, pnorm(48, 42, 4) - pnorm(36, 42, 4), gives 0.87: the band in the middle, exactly the opposite of what is asked.

2 * pnorm(-1.5)

Output:

[1] 0.1336144

0.13: 13 % of the sacks are 6 minutes or more from the mean (above or below).

(c) “What only 10 % exceed” leaves 10 % on the right, so it leaves 90 % on the left: it is the 0.90 quantile.

Why 0.90 and not 0.10. qnorm takes the area on the left, and the question gives the one on the right: if 10 % is left to the right of t t , 90 % is left to its left. That translation is the step I skipped in the practice exam at the start.

P(T>t)=0.10  ⟺  P(T≤t)=0.90  ⟺  t=42+z0.90⋅4=42+1.2816⋅4 P(T > t) = 0.10 \iff P(T \le t) = 0.90 \iff t = 42 + z_{0.90}\cdot 4 = 42 + 1.2816 \cdot 4
qnorm(0.90, 42, 4)

Output:

[1] 47.12621

47.13 minutes. Check: it is above the mean, as it should be if we are talking about the slowest sacks.

(d) H=T60H = \frac{T}{60} is aT+baT + b with a=160a = \frac{1}{60}, b=0b = 0. By the aX+baX + b result:

H∼N(4260, 460)=N(0.70, 0.0667) H \sim N\left(\frac{42}{60},\ \frac{4}{60}\right) = N(0.70,\ 0.0667)

Why aT+b aT + b . Turning 0.75 hours into 45 minutes gives the number, but the part also asks for the distribution of H H , and for that the mean and the standard deviation are both divided by 60.

Dividing only the mean. With N(0.70, 4) N(0.70,\ 4) you get 0.50 instead of 0.23. If changing units changes a probability, you have transformed some parameter wrongly.

1 - pnorm(0.75, 42 / 60, 4 / 60)

Output:

[1] 0.2266274

0.23, the same as in (a), because it is the same event: H>0.75  ⟺  T>45H > 0.75 \iff T > 45 (three quarters of an hour are 45 minutes). Changing units does not change probabilities.

(e) For one sack, p=P(T>50)=1−Φ(2)p = P(T > 50) = 1 – \Phi(2). The number of slow sacks out of 5, NN, is binomial B(5,p)B(5, p) (the times are independent), and “at least one” is the complement of “none”:

P(N≥1)=1−P(N=0)=1−(1−p)5 P(N \ge 1) = 1 – P(N = 0) = 1 – (1 – p)^5

Why a binomial. The normal gives the probability for one sack; “at least one out of five” is counting successes in 5 independent trials. The shortcut 5p=0.1138 5p = 0.1138 counts the days with two slow sacks twice, and that is why it comes out too high. With “at least one”, go to the complement: “none” is a single calculation.

Check you’ve got it: what is the probability that none of the five sacks takes more than 50 minutes?

P(N=0)=(1−p)5=0.97725=0.89 P(N = 0) = (1 – p)^5 = 0.9772^5 = 0.89 . It is the complement of (e): 1−0.1087=0.8913 1 – 0.1087 = 0.8913 . If the two do not add up to 1, one of them is wrong.

p <- 1 - pnorm(50, 42, 4)
c(p, 1 - (1 - p)^5)

Output:

[1] 0.02275013 0.10869139

p=0.0228p = 0.0228 and P(N≥1)=0.11P(N \ge 1) = 0.11: a sack takes more than 50 minutes only 2.28 % of the time, but on a five-sack day it happens on 10.87 % of days.

How it is marked (a guide, not official): in each part, 1 mark for the setup (the distribution written correctly, the event and the right standardisation or quantile) and 1 for the result. In (a), giving N(42,16)N(42, 16) in R gets half the setup mark and 0 for the result. In (d), half a mark is the sentence explaining why it matches (a). In (e), without the binomial (for example, 5p5p) there is no result mark.

Exercise 2

The plan for (a), before the algebra. Without the mgf you would need a convolution, an integral that with n n normals cannot be done in an exam. With independence, the mgf of the sum is a product, and a product of exponentials is a single exponential. There are three steps, and each one earns marks: the product, grouping in t t and in t2 t^2 , and recognising the mgf of a normal.

(a) By independence, the mgf of the sum is the product of the mgfs:

φX1+⋯+Xn(t)=∏i=1nφXi(t)=∏i=1neμit+12σi2t2=e(∑μi)t+12(∑σi2)t2 \varphi_{X_1 + \cdots + X_n}(t) = \prod_{i=1}^{n} \varphi_{X_i}(t) = \prod_{i=1}^{n} e^{\mu_i t + \frac{1}{2}\sigma_i^2 t^2} = e^{\left(\sum \mu_i\right) t + \frac{1}{2}\left(\sum \sigma_i^2\right) t^2}

When multiplying exponentials the exponents add, and the terms in tt and t2t^2 are grouped. The result is the mgf of a normal with mean ∑μi\sum \mu_i and variance ∑σi2\sum \sigma_i^2. Since the mgf characterises the distribution:

X1+⋯+Xn∼N(∑i=1nμi, ∑i=1nσi2) X_1 + \cdots + X_n \sim N\left(\sum_{i=1}^n \mu_i,\ \sqrt{\sum_{i=1}^n \sigma_i^2}\right)

(b) W=X1+⋯+X12+CW = X_1 + \cdots + X_{12} + C, thirteen independent normals. By (a):

E(W)=12⋅1010+240=12360,Var(W)=12⋅62+102=532,W∼N(12360, 23.07) E(W) = 12 \cdot 1010 + 240 = 12360, \qquad \mathrm{Var}(W) = 12 \cdot 6^2 + 10^2 = 532, \qquad W \sim N(12360,\ 23.07)

Why 12⋅62 12 \cdot 6^2 and not 122⋅62 12^2 \cdot 6^2 . They are 12 different packets, each with its own variance 36, and the 12 are added. 12X 12X would be a single packet multiplied by 12, as if they all weighed the same and their errors never cancelled out.

Writing W=12X+C W = 12X + C . It gives σW=72.69 \sigma_W = 72.69 and P(W>12400)=0.29 P(W > 12400) = 0.29 , seven times the correct value.

mW <- 12 * 1010 + 240; sW <- sqrt(12 * 6^2 + 10^2)
c(mW, sW, 1 - pnorm(12400, mW, sW))

Output:

[1] 1.236000e+04 2.306513e+01 4.143953e-02

σW=23.07\sigma_W = 23.07 and P(W>12400)=0.0414P(W > 12400) = 0.0414: a bit more than 4 % of the boxes exceed 12.4 kg. The cardboard, although it weighs little, adds 100 to the variance, almost a quarter of the packets’ 432.

(c) Xˉ=19∑Xi\bar{X} = \frac{1}{9}\sum X_i: by (a), the sum is N(9⋅1010, 69)N(9 \cdot 1010,\ 6\sqrt{9}), and multiplying by 19\frac{1}{9}:

Xˉ∼N(1010, 69)=N(1010, 2),P(Xˉ<1006)=Φ(1006−10102)=Φ(−2) \bar{X} \sim N\left(1010,\ \frac{6}{\sqrt{9}}\right) = N(1010,\ 2), \qquad P(\bar{X} < 1006) = \Phi\left(\frac{1006 – 1010}{2}\right) = \Phi(-2)

Why it drops to 2. The sum has standard deviation 69=18 6\sqrt{9} = 18 , and dividing by 9 leaves 2: in the mean, the packets that weigh too much and the ones that weigh too little cancel out.

Check you’ve got it: if the inspector weighed 36 packets, what would P(Xˉ<1006) P(\bar{X} < 1006) be?

The standard deviation of the mean would be 6/36=1 6 / \sqrt{36} = 1 , and pnorm(1006, 1010, 1) gives 0.00003. With four times as many packets, the standard deviation is halved, not divided by four: it goes with the square root of n n .

pnorm(1006, 1010, 6 / 3)

Output:

[1] 0.02275013

0.0228: only 2.28 % of the time does the mean of 9 packets drop below 1006 g, even though a single packet does it much more often (pnorm(1006, 1010, 6) = 0.25).

(d) D=X−YD = X – Y, with XX and YY independent: D∼N(1010−1004, 62+42)=N(6, 7.21)D \sim N\left(1010 – 1004,\ \sqrt{6^2 + 4^2}\right) = N(6,\ 7.21), and P(X>Y)=P(D>0)P(X > Y) = P(D > 0).

Why a difference. pnorm only asks about one variable, so everything is moved to one side: X>Y  ⟺  X−Y>0 X > Y \iff X – Y > 0 . The variance adds even when you subtract, because Var(−Y)=(−1)2 Var(Y) \mathrm{Var}(-Y) = (-1)^2\,\mathrm{Var}(Y) . And to compare the labels, look at how many standard deviations each mean is from 1000: 10/6=1.67 10 / 6 = 1.67 against 4/4=1 4 / 4 = 1 . The one further away wins, not the more precise one.

c(1 - pnorm(0, 6, sqrt(52)), pnorm(1000, 1010, 6), pnorm(1000, 1004, 4))

Output:

[1] 0.79730972 0.04779035 0.15865525

P(X>Y)=0.80P(X > Y) = 0.80: in eight pairs out of ten the packet from the first machine is heavier. And for packets under 1 kg, the first machine has 4.78 % and the second 15.87 %: although it is more precise (σ=4\sigma = 4), its mean is too close to 1000 (just one standard deviation away). For the label, as things stand, the first one is better.

(e)

set.seed(2026)
W <- replicate(10000, sum(rnorm(12, 1010, 6)) + rnorm(1, 240, 10))
round(c(mean(W), sd(W), mean(W > 12400)), 4)

Output:

[1] 12360.0487    23.4719     0.0447

The simulated mean (12,360.05) and standard deviation (23.47) are close to the theoretical ones (12,360 and 23.07), and the proportion of boxes over 12.4 kg, 0.0447, close to 0.0414. The difference is randomness: in a 4 % tail, with 10,000 boxes, the standard error of the proportion is about two thousandths.

How it is marked (a guide, not official): (a) 2 marks for the product of mgfs citing independence, 1 for grouping the exponents and 1 for concluding with the uniqueness of the mgf; (b) 1 for the mean, 1 for the variance (adding all 13) and 1 for the probability; (c) 1 for the distribution of the mean and 1 for the result; (d) 1 for the distribution of DD (with the variances added), 1 for P(D>0)P(D > 0) and 1 for the reasoned comparison; (e) 2 for the code and 1 for commenting that it matches.

Exercise 3

(a)

bags <- c(511.7, 506.0, 509.2, 508.0, 508.1, 507.2, 507.0, 513.6, 506.2, 504.7,
          507.5, 511.5, 501.9, 509.8, 502.9, 509.1, 504.7, 514.6, 503.0, 505.6,
          504.8, 510.5, 504.3, 508.0, 509.8, 508.6, 503.7, 507.5, 502.9, 515.6,
          506.3, 504.8, 503.5, 505.0, 505.2, 509.9, 506.4, 506.6, 507.9, 510.8)
m <- mean(bags); s <- sd(bags)
round(c(m, s), 2)
summary(bags)
hist(bags, freq = FALSE, col = "grey90", main = "40 bags", xlab = "grams")
curve(dnorm(x, m, s), add = TRUE, lwd = 2, col = "red")

Output:

[1] 507.36   3.27
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  501.9   504.8   507.1   507.4   509.4   515.6 

Mean 507.36 g and standard deviation 3.27 g. The median (507.1) is very close to the mean: the data are fairly symmetric.

Why freq = FALSE. The bell has area 1; a frequency histogram has 40⋅2=80 40 \cdot 2 = 80 (data points times bar width). Without freq = FALSE, the curve would come out squashed against the axis.

The 40 bags and the fitted normalDensity-scale histogram of 40 bags, with 2 gram bars between 500 and 516: heights 0.0125, 0.0625, 0.1125, 0.1375, 0.0875, 0.05, 0.0125 and 0.025. On top, the red curve of the normal with mean 507.36 and standard deviation 3.27.0.000.050.100.15500504508512516gramsdensitydnorm(x, 507.36, 3.27)40 bags
Redrawn with the site colours: the bell follows the bars; the teeth on the right are one or two bags.

In the histogram (2 g bars, the ones R chooses), the bars rise up to the 506-508 g one, the tallest (0.1375), and fall, with the red bell following the outline. There is a low bar at 512-514 and a slightly taller one at 514-516: with 40 data points, one or two bags of difference already make those teeth.

(b)

qqnorm(bags); qqline(bags, col = "red", lwd = 2)
Quantile-quantile plot of the 40 bagsForty points, one per bag: horizontally the theoretical quantile, from minus 2.24 to 2.24, and vertically the weight, from 501.9 to 515.6. Almost all fall on the red qqline, with slope 3.37; the five lightest lie slightly above the line, and so do the three heaviest, in coral.500505510515-2-1012Theoretical quantiles (standard normal)Sample quantilesqqline: slope 3.37
Redrawn with the site colours: almost a straight line; the ends drift a little, with no curve or S shape.

The points in the middle are on the line. At the left end, the five lightest lie slightly above it: the lightest bags weigh a bit more than a normal would predict (the left tail is a bit shorter). On the right, the three heaviest (513.6, 514.6 and 515.6 g) also drift upwards (a slightly longer right tail). These are small deviations, with no curve or S shape across the whole plot: the normal model is reasonable. If anything, the short left tail makes the model cautious about bags under 500 g: it predicts a few more than there probably are.

(c)

round(c(data = mean(bags < 500), model = pnorm(500, m, s)), 4)

Output:

  data  model 
0.0000 0.0123 

In the data, no bag weighs less than 500 g (the lightest, 501.9); the model says 1.23 %. They do not contradict each other: with 40 bags, the probability of seeing none short when the true proportion is 0.0123 is 0.987740=0.610.9877^{40} = 0.61. The most likely outcome is to see none. That is exactly what the model is for: estimating a small proportion that the sample is too short to show.

(d) The absolute value is an interval: ∣X−μ∣≤cσ  ⟺  μ−cσ≤X≤μ+cσ|X – \mu| \le c\sigma \iff \mu – c\sigma \le X \le \mu + c\sigma. Standardising with Z=X−μσ∼N(0,1)Z = \frac{X – \mu}{\sigma} \sim N(0, 1) (dividing by σ>0\sigma > 0 does not change the direction):

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

For 90 %: 2Φ(c)−1=0.90  ⟺  Φ(c)=0.95  ⟺  c=z0.952\Phi(c) – 1 = 0.90 \iff \Phi(c) = 0.95 \iff c = z_{0.95}.

Using qnorm(0.90). The middle 90 % leaves 5 % on each side, so the right-hand end leaves 95 % to its left. With c=1.28 c = 1.28 , the interval only contains 80 % of the bags.

cc <- qnorm(0.95)
round(c(cc, m - cc * s, m + cc * s), 2)

Output:

[1]   1.64 501.98 512.74

c=1.64c = 1.64 and the interval is (501.98, 512.74) g: 90 % of the bags weigh between 501.98 and 512.74 g, 507.36±1.64⋅3.27507.36 \pm 1.64 \cdot 3.27.

(e) We want P(X<500)=0.005P(X < 500) = 0.005 with X∼N(μ, 3.27)X \sim N(\mu,\ 3.27):

500−μ3.27=z0.005=−2.5758⟹μ=500−z0.005⋅3.27=500+2.5758⋅3.27 \frac{500 – \mu}{3.27} = z_{0.005} = -2.5758 \quad\Longrightarrow\quad \mu = 500 – z_{0.005}\cdot 3.27 = 500 + 2.5758 \cdot 3.27

Why μ \mu is the unknown now. It is the same standardisation with a different unknown: the point and the probability come from the question, and what is missing is where to put the center of the bell. 500 has to sit 2.58 standard deviations below the mean. If you lose the sign of z0.005 z_{0.005} when solving, you get μ=491.57 \mu = 491.57 , below 500: more than half of the bags would be short.

Check you’ve got it: where would the mean have to be for only 0.1 % of the bags to weigh less than 500 g?

Now z0.001=−3.09 z_{0.001} = -3.09 , and 500 - qnorm(0.001) * s gives 510.11 g: almost two grams more gofio per bag than with 0.5 %.

round(500 - qnorm(0.005) * s, 2)

Output:

[1] 508.43

508.43 g: the mean has to go up by just over a gram, from 507.36 to 508.43. Check: 2.5758⋅3.27=8.432.5758 \cdot 3.27 = 8.43, and above 500, as it should be.

How it is marked (a guide, not official): (a) 1 for the mean and standard deviation, 1 for the histogram with freq = FALSE and 1 for the curve with the estimated parameters; (b) 1 for the plot and 1 for a comment saying what can be seen (“it is normal” is not enough); (c) 1 for the two proportions and 1 for explaining the difference; (d) 2 for the proof (interval, standardising and symmetry) and 2 for the 90 % interval; (e) 2 for setting it up with z0.005z_{0.005} and solving with the right sign, 2 for the value.

Bonus

∣z∣ φ(z)|z|\,\varphi(z) is even, so, by symmetry, the integral is twice that over (0,∞)(0, \infty), where ∣z∣=z|z| = z:

E(∣Z∣)=2∫0∞z 12π e−z22 dz=22π[−e−z22]0∞=22π (0+1)=2π E(|Z|) = 2\int_{0}^{\infty} z\, \frac{1}{\sqrt{2\pi}}\, e^{-\frac{z^2}{2}}\, dz = \frac{2}{\sqrt{2\pi}}\left[-e^{-\frac{z^2}{2}}\right]_{0}^{\infty} = \frac{2}{\sqrt{2\pi}}\,(0 + 1) = \sqrt{\frac{2}{\pi}}

The antiderivative works because zz is the derivative (up to the sign) of the exponent. For X=μ+σZX = \mu + \sigma Z: ∣X−μ∣=σ∣Z∣|X – \mu| = \sigma|Z|, and

E(∣X−μ∣)=σ E(∣Z∣)=σ2π≈0.80 σ E(|X – \mu|) = \sigma\,E(|Z|) = \sigma\sqrt{\frac{2}{\pi}} \approx 0.80\,\sigma
integrate(function(z) abs(z) * dnorm(z), -Inf, Inf)$value
c(sqrt(2 / pi), 6 * sqrt(2 / pi))

Output:

[1] 0.7978846
[1] 0.7978846 4.7873074

On average, a packet is 4.79 g away from 1010 g (0.7979⋅60.7979 \cdot 6). It is a bit less than the standard deviation, because σ\sigma gives more weight to large distances (it squares them).

How it is marked (a guide, not official): 1 mark for using evenness and setting up the integral over (0,∞)(0, \infty), 1 for the antiderivative and the value, and 0.5 for the step to σ2/π\sigma\sqrt{2/\pi} and the 4.79 g.

What’s wrong here?

Three solutions from a classmate, each with one of the most common mistakes. Predict the correct result before reading the explanation.

Fragment 1. “The weight of a bag is normal with mean 507 and variance 9. The probability that it weighs less than 500 g is:”

pnorm(500, 507, 9)

Output:

[1] 0.21835

It gives 0.2184: more than one bag in five below the weight. But the third argument of pnorm is the standard deviation, and the statement’s is 9=3\sqrt{9} = 3. The correct call is pnorm(500, 507, 3) = 0.0098, less than 1 %.

Mixing up σ\sigma and σ2\sigma^2. Before typing pnorm, write sigma <- sqrt(9) on its own line and use sigma: that way the script shows which number is which.

Fragment 2. “What grinding time do only 10 % of the sacks exceed, with T∼N(42,4)T \sim N(42, 4)?”

qnorm(0.10, 42, 4)

Output:

[1] 36.87379

36.87 minutes: below the mean, when the question is about the slowest sacks. qnorm leaves the probability you give it on the left: this is the value only 10 % do not exceed (the mistake in the anecdote at the start). The correct call is qnorm(0.90, 42, 4) = 47.13, or qnorm(0.10, 42, 4, lower.tail = FALSE).

"What only 10 % exceed": the right tailThe normal 42 4 bell of the milling times. On the left, the violet 10 percent tail up to 36.87, which is what qnorm of 0.10 gives, and is wrong. On the right, the coral 10 percent tail from 47.13, qnorm of 0.90, which is what was asked.0.000.050.103036.874247.1354Milling minutes, N(42, 4)f(t)qnorm(0.10, 42, 4)the fastest: wrongqnorm(0.90, 42, 4)the slowest: right10 %10 %
Both answers are 5.13 minutes from the mean, one on each side. Only the right one is about the slowest sacks.

In the drawing, the two answers on the bell: the classmate’s leaves 10 % on the left (violet tail) and the correct one, on the right (coral tail). They are the same distance from 42, one on each side.

Sign check: if you are asked about “the ones that most” and you get a value below the mean (or the other way round), you have taken the wrong tail.

Fragment 3. “With X∼N(1010,6)X \sim N(1010, 6) and Y∼N(1004,4)Y \sim N(1004, 4) independent, the difference X−YX – Y has standard deviation 6−4=26 – 4 = 2, so”

1 - pnorm(0, 6, 2)

Output:

[1] 0.9986501

0.9987: according to the classmate, the first machine’s packet is almost always heavier. But subtracting two independent variables does not subtract their spread: Var(X−Y)=36+16=52\mathrm{Var}(X – Y) = 36 + 16 = 52, σ=7.21\sigma = 7.21, and the probability is 1 - pnorm(0, 6, sqrt(52)) = 0.7973. With σ=2\sigma = 2 you invent a precision that does not exist.

If the standard deviation of a difference comes out smaller than that of either variable, you have subtracted something that adds.

Practice quiz

Before moving on to the next topic, check you have got it. This quiz is here to consolidate what this article explains: the ME1 exam is not a multiple-choice test (you solve problems by hand and with R), so no mark here counts. There are 10 questions on the normal distribution: key ideas, typical mistakes and many «what does this R code print?», with the outputs from really running it. In the short answers, a decimal point or a decimal comma both work. Answer without running anything, press Check and read the explanation for each option; you can repeat it as many times as you like.

Question 1Single choice

A bag’s weight is normal with mean 507 g and variance 9. Which command gives P(weight < 500)?

  1. pnorm(500, 507, 3)
  2. pnorm(500, 507, 9)
  3. 1 - pnorm(500, 507, 3)
  4. dnorm(500, 507, 3)
Solution

Answer: pnorm(500, 507, 3)

Before pnorm, write sigma <- sqrt(9) and use sigma: then the script shows which number is which. Mixing up σ and σ² is the topic’s most repeated mistake.

Question 2Short answer

T ~ N(42, 4) minutes. Which time is exceeded by only the slowest 10 % of sacks? (2 decimals.)

round(qnorm(0.90, 42, 4), 2)
Solution

Answer: 47.13

qnorm leaves the probability you give it to the left: for 10 % to be above, ask for the 0.90 quantile. With qnorm(0.10, 42, 4) you get 36.87, below the mean: the wrong tail.

Question 3Single choice

X ~ N(1010, 6) and Y ~ N(1004, 4) are independent. What is the standard deviation of X − Y?

  1. √(36 + 16) = √52 = 7.21
  2. 6 − 4 = 2
  3. 6 + 4 = 10
  4. √(36 − 16) = 4.47
Solution

Answer: √(36 + 16) = √52 = 7.21

If the standard deviation of a difference comes out smaller than that of either variable, you subtracted something that adds.

Question 4Short answer

With X ~ N(1010, 6) and Y ~ N(1004, 4) independent, what does it print? (It is P(X > Y).)

round(1 - pnorm(0, 1010 - 1004, sqrt(6^2 + 4^2)), 4)
Solution

Answer: 0.7973

X − Y ~ N(6, √52): P(X − Y > 0) = 1 − pnorm(0, 6, 7.21) = 0.7973.

Question 5Short answer

A box holds 12 independent packs, each N(1030, 6.66) grams. What is the standard deviation of the box’s weight? (2 decimals.)

round(sqrt(12) * 6.66, 2)
Solution

Answer: 23.07

Sum of 12 identical independent variables: mean 12 · 1030 = 12360 and variance 12 · 6.66², so σ = 6.66 · √12 = 23.07. It is the exercise’s box, N(12360; 23.07).

Question 6True or false

True or false about the normal?

  1. In a normal, mean, median and mode coincide.
  2. The bell’s inflection points are at μ ± σ.
  3. P(|X − μ| ≤ 2σ) is exactly 0.95.
  4. If X ~ N(μ, σ), then Z = (X − μ)/σ ~ N(0, 1).
Solution
  • T — In a normal, mean, median and mode coincide.
  • T — The bell’s inflection points are at μ ± σ.
  • F — P(|X − μ| ≤ 2σ) is exactly 0.95.
  • T — If X ~ N(μ, σ), then Z = (X − μ)/σ ~ N(0, 1).

It is 0.9545 (the 68-95-99.7 rule rounds). The exact 0.95 corresponds to ±1.96σ.

Question 7Match

Match each R command with what it computes, for X ~ N(μ, σ):

pnorm(x, mu, sigma)
1 – pnorm(x, mu, sigma)
qnorm(p, mu, sigma)
qnorm(p, mu, sigma, lower.tail = FALSE)

Definitions:

  • The variance of X
  • The value leaving p to the right
  • The value leaving p to the left
  • P(X > x)
  • P(X ≤ x)
Solution
  • pnorm(x, mu, sigma) → P(X ≤ x)
  • 1 – pnorm(x, mu, sigma) → P(X > x)
  • qnorm(p, mu, sigma) → The value leaving p to the left
  • qnorm(p, mu, sigma, lower.tail = FALSE) → The value leaving p to the right

Sign check: if you are asked about «the ones that most…» and you get a value below the mean, you took the wrong tail.

Question 8Short answer

What does it print? (It is the one-standard-deviation rule.)

round(pnorm(1) - pnorm(-1), 4)
Solution

Answer: 0.6827

P(−1 ≤ Z ≤ 1) = 0.6827: the 68 % of the empirical rule. With 2 and 3 you get 0.9545 and 0.9973.

Question 9Single choice

To add the variances of X and Y in X − Y or X + Y, what must you be able to say first?

  1. That X and Y are independent
  2. That they have the same mean
  3. That they have the same standard deviation
  4. That they are positive
Solution

Answer: That X and Y are independent

In the exam, write «independent» before adding variances: it earns marks.

Question 10Short answer

Z ~ N(0, 1). What does it print? (2 decimals.)

round(qnorm(0.975), 2)
Solution

Answer: 1.96

The value leaving 0.975 to the left (and 0.025 to the right) is 1.96: between −1.96 and 1.96 lies the central 95 %. You will see it in every confidence interval.

Try it in the R playground

Open the site’s R playground (or RStudio) and paste this script. It is the whole of exercise 3, so you can do it with the plots in front of you:

bags <- c(511.7, 506.0, 509.2, 508.0, 508.1, 507.2, 507.0, 513.6, 506.2, 504.7,
          507.5, 511.5, 501.9, 509.8, 502.9, 509.1, 504.7, 514.6, 503.0, 505.6,
          504.8, 510.5, 504.3, 508.0, 509.8, 508.6, 503.7, 507.5, 502.9, 515.6,
          506.3, 504.8, 503.5, 505.0, 505.2, 509.9, 506.4, 506.6, 507.9, 510.8)
m <- mean(bags); s <- sd(bags)
hist(bags, freq = FALSE); curve(dnorm(x, m, s), add = TRUE, lwd = 2, col = "red")
qqnorm(bags); qqline(bags, col = "red")
c(mean(bags < 500), pnorm(500, m, s))
m + c(-1, 1) * qnorm(0.95) * s        # the central 90 %
500 - qnorm(0.005) * s                # the mean for 0.5 % short

What to look at:

  1. In Plots, the histogram with the bell; with the Plots arrow go back to the quantile-quantile plot and compare the two.
  2. Change qnorm(0.95) to qnorm(0.975): the interval now contains 95 %. How much wider does it get?
  3. Try pnorm(500, m, var(bags)): it is fragment 1. Compare it with pnorm(500, m, s).
  4. Add abline(v = 500, lty = 2) after the histogram: the line for the label weight, to the left of all the bars.
  5. Type ?qnorm and look for lower.tail in Help.

Cheat sheet: the normal distribution

The essentials in 30 seconds. X∼N(μ,σ)X \sim N(\mu, \sigma), with the standard deviation (in R, sd). Symmetric about μ\mu: mean = median = mode = μ\mu; inflection at μ±σ\mu \pm \sigma. E(X)=μE(X) = \mu, Var(X)=σ2\mathrm{Var}(X) = \sigma^2, φX(t)=eμt+12σ2t2\varphi_X(t) = e^{\mu t + \frac{1}{2}\sigma^2t^2}. Standardise: Z=X−μσ∼N(0,1)Z = \frac{X – \mu}{\sigma} \sim N(0,1), X=μ+σZX = \mu + \sigma Z. Combinations of independents: means with their sign, variances added.

I want…FormulaIn R
P(X≤x)P(X \le x)Φ(x−μσ)\Phi\left(\frac{x – \mu}{\sigma}\right)pnorm(x, mu, sigma)
P(X>x)P(X > x)1−Φ(x−μσ)1 – \Phi\left(\frac{x – \mu}{\sigma}\right)1 - pnorm(x, mu, sigma)
P(a<X<b)P(a < X < b)Φ(zb)−Φ(za)\Phi(z_b) – \Phi(z_a)pnorm(b, …) - pnorm(a, …)
P(∣X−μ∣≤cσ)P(\lvert X – \mu\rvert \le c\sigma)2Φ(c)−12\Phi(c) – 12 * pnorm(c) - 1
The value with P(X≤x)=pP(X \le x) = pμ+zpσ\mu + z_p\sigmaqnorm(p, mu, sigma)
The value with P(X>x)=pP(X > x) = pμ+z1−pσ\mu + z_{1-p}\sigmaqnorm(1 - p, mu, sigma)
The mean for P(X<L)=pP(X < L) = pL−zpσL – z_p\sigmaL - qnorm(p) * sigma
The σ\sigma for P(X<L)=pP(X < L) = pL−μzp\frac{L – \mu}{z_p}(L - mu) / qnorm(p)
Simulate—rnorm(n, mu, sigma)
Check whether data are normal—hist(x, freq = FALSE), qqnorm(x); qqline(x)
Combination (independent)MeanStandard deviation
aX+baX + baμ+ba\mu + b∣a∣σ\lvert a\rvert\sigma
X+YX + Y and X−YX – YμX±μY\mu_X \pm \mu_YσX2+σY2\sqrt{\sigma_X^2 + \sigma_Y^2}
Sum of nn equalnμn\muσn\sigma\sqrt{n}
Mean of nn equalμ\muσ/n\sigma/\sqrt{n}
Quantilez0.90z_{0.90}z0.95z_{0.95}z0.975z_{0.975}z0.99z_{0.99}z0.995z_{0.995}
Value1.28161.64491.96002.32632.5758

68-95-99.7 rule: P(∣X−μ∣≤kσ)P(\lvert X – \mu\rvert \le k\sigma) = 0.6827, 0.9545 and 0.9973 for k=1,2,3k = 1, 2, 3. Others: ∫e−x2/2dx=2π\int e^{-x^2/2}dx = \sqrt{2\pi}; E(Z4)=3E(Z^4) = 3; E(∣Z∣)=2/πE(\lvert Z\rvert) = \sqrt{2/\pi}; E(eX)=eμ+σ2/2E(e^{X}) = e^{\mu + \sigma^2/2}.

SymptomLikely cause
An absurd probability (39 % short packets)The variance in place of sd
A quantile on the wrong side of the meanqnorm(p) instead of qnorm(1 - p)
integrate(dnorm, -Inf, Inf, mean = 1010, …) gives 0Bell far from 0: use finite limits
The dnorm curve comes out stuck to the histogram axisfreq = FALSE is missing
The standard deviation of a difference is smaller than bothVariances were subtracted
A mean for “only 1 % below” that is below the limitThe sign of zpz_p when solving

Before handing in, ask yourself:

  1. Have I turned the variance into a standard deviation before using R?
  2. Have I drawn the tail I am asked for and used 1 - or 1 - p where needed?
  3. Have I said “independent” before adding variances?
  4. Do my results have 2 decimals (and 4 for small probabilities) and is the code in the script?
ME1 exam coming up?The script for every topic, the printable cheat sheet and the pack for each exam, for free.See the pack

For your script

The topic’s code, commented and tested, to copy into your exam .R file. They are short functions: you pass them the data from the statement and they return the result.

# ---------- Normal distribution (ME1, topic 5) ----------
# Remember: in R, N(mu, sigma) with the STANDARD DEVIATION. If given the variance, sigma <- sqrt(var)

# P(X <= x), P(X > x) and P(a < X < b)
p_below   <- function(x, mu, sigma) pnorm(x, mu, sigma)
p_above   <- function(x, mu, sigma) pnorm(x, mu, sigma, lower.tail = FALSE)
p_between <- function(a, b, mu, sigma) pnorm(b, mu, sigma) - pnorm(a, mu, sigma)
# P(|X - mu| <= c) and P(|X - mu| >= c), with c in the units of X
p_near    <- function(c, sigma) 2 * pnorm(c / sigma) - 1
p_far     <- function(c, sigma) 2 * pnorm(-c / sigma)
# Standardise and go back
standardise   <- function(x, mu, sigma) (x - mu) / sigma
unstandardise <- function(z, mu, sigma) mu + sigma * z
# The value leaving p on the left / the one only a proportion p exceeds
quantile_left  <- function(p, mu, sigma) qnorm(p, mu, sigma)
quantile_right <- function(p, mu, sigma) qnorm(p, mu, sigma, lower.tail = FALSE)
# Adjust: the mean (or the sigma) so that P(X < L) = p
mean_for  <- function(L, p, sigma) L - qnorm(p) * sigma
sigma_for <- function(L, p, mu) (L - mu) / qnorm(p)
# Combinations of INDEPENDENT normals: a1*X1 + ... + ak*Xk + b
combine <- function(a, mu, sigma, b = 0) c(mean = sum(a * mu) + b, sd = sqrt(sum(a^2 * sigma^2)))
# Check whether data are normal and fit the bell
check_normal <- function(x, ...) {
  m <- mean(x); s <- sd(x)
  op <- par(mfrow = c(1, 2)); on.exit(par(op))
  hist(x, freq = FALSE, col = "grey90", main = "Histogram", ...)
  curve(dnorm(x, m, s), add = TRUE, lwd = 2, col = "red")
  qqnorm(x); qqline(x, col = "red", lwd = 2)
  round(c(mean = m, sd = s), 2)
}

# ---------- Examples (the exercises in this article) ----------
round(p_above(45, 42, sqrt(16)), 2)            # ex. 1 (a)
round(p_far(6, 4), 4)                          # ex. 1 (b)
round(quantile_right(0.10, 42, 4), 2)          # ex. 1 (c)
W <- combine(a = rep(1, 13), mu = c(rep(1010, 12), 240), sigma = c(rep(6, 12), 10))
W; round(p_above(12400, W["mean"], W["sd"]), 4)   # ex. 2 (b)
D <- combine(a = c(1, -1), mu = c(1010, 1004), sigma = c(6, 4))
round(p_above(0, D["mean"], D["sd"]), 4)       # ex. 2 (d)
round(mean_for(500, 0.005, 3.27), 2)           # ex. 3 (e)

Output:

[1] 0.23
[1] 0.1336
[1] 47.13
       mean          sd 
12360.00000    23.06513 
[1] 0.0414
[1] 0.7973
[1] 508.42

The combine function is the one that pays off most: you pass it the coefficients aia_i, the means and the standard deviations, and it adds the means and takes the square root of the sum of ai2σi2a_i^2\sigma_i^2. With a = c(1, -1) it is the difference, and the variances add on their own because (−1)2=1(-1)^2 = 1. The results match the solutions: 0.23, 0.1336, 47.13, the box N(12360, 23.07)N(12360,\ 23.07) with 0.0414, the difference with 0.7973 and the mean of 508.42 g (508.43 in the solution, which uses the unrounded σ\sigma; here it is given 3.27). Copy check_normal too: it draws the histogram with the bell and the quantile-quantile plot in one go.

What comes next?

With the normal you now have all the one-variable models. The next ME1 topic puts two variables together: transformations of variables and joint distributions (joint density, marginals, independence, covariance and correlation), where you will see what happens to the variance of a sum when the variables are not independent. After that come the limit theorems, which explain why so many things are normal.

If you want to revise first, you have the theory, the proofs and the practice for this topic, and continuous random variables, where the density, the FF and the mgf we have used come from.

Keep goingAll Statistics articles

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

Ready for the exam?ME1 EC2 mock exam — 4 hours with R beside you, from the normal to confidence intervals, four versions and a mark out of 50 (and why exercise 1 is worth double)