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.
Table of Contents
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
.Rfile with the code for each exercise. - Draw the bell before every
pnormorqnorm. 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
.Rfile. 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, , in minutes, follows a normal distribution with mean 42 minutes and variance 16.
(a) Write the distribution of in R notation and compute the probability that a sack takes more than 45 minutes. (2 marks)
(b) By standardising, express in terms of and compute it with R. (2 marks)
(c) Compute the time that only 10 % of the sacks exceed. (2 marks)
(d) Let be the grinding time in hours. Give its distribution and compute . 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, . The packets go 12 at a time into a cardboard box whose weight is . All weights are independent.
(a) Prove, using the moment generating function, that if are independent with , then is normal, and give its mean and standard deviation. (4 marks)
(b) Let 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, . Give the distribution of and the probability that it is below 1006 g. (2 marks)
(d) A second machine fills with . 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 and . Prove that . 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 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), is negative: careful with the sign when solving.
Bonus (2.5 marks)
Let . Compute by integrating and deduce for . 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: , and in R pnorm(…, 42, 4).
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: or . Standardising, :
The last equality is by symmetry: .
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 , 90 % is left to its left. That translation is the step I skipped in the practice exam at the start.
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) is with , . By the result:
Why . Turning 0.75 hours into 45 minutes gives the number, but the part also asks for the distribution of , and for that the mean and the standard deviation are both divided by 60.
Dividing only the mean. With 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: (three quarters of an hour are 45 minutes). Changing units does not change probabilities.
(e) For one sack, . The number of slow sacks out of 5, , is binomial (the times are independent), and “at least one” is the complement of “none”:
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 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?
. It is the complement of (e): . 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
and : 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 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, ) 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 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 and in , and recognising the mgf of a normal.
(a) By independence, the mgf of the sum is the product of the mgfs:
When multiplying exponentials the exponents add, and the terms in and are grouped. The result is the mgf of a normal with mean and variance . Since the mgf characterises the distribution:
(b) , thirteen independent normals. By (a):
Why and not . They are 12 different packets, each with its own variance 36, and the 12 are added. would be a single packet multiplied by 12, as if they all weighed the same and their errors never cancelled out.
Writing . It gives and , 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
and : 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) : by (a), the sum is , and multiplying by :
Why it drops to 2. The sum has standard deviation , 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 be?
The standard deviation of the mean would be , 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 .
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) , with and independent: , and .
Why a difference. pnorm only asks about one variable, so everything is moved to one side: . The variance adds even when you subtract, because . And to compare the labels, look at how many standard deviations each mean is from 1000: against . 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
: 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 (), 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 (with the variances added), 1 for 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 (data points times bar width). Without freq = FALSE, the curve would come out squashed against the axis.
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)
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 . 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: . Standardising with (dividing by does not change the direction):
For 90 %: .
Using qnorm(0.90). The middle 90 % leaves 5 % on each side, so the right-hand end leaves 95 % to its left. With , 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
and the interval is (501.98, 512.74) g: 90 % of the bags weigh between 501.98 and 512.74 g, .
(e) We want with :
Why 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 when solving, you get , 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 , 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: , 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 and solving with the right sign, 2 for the value.
Bonus
is even, so, by symmetry, the integral is twice that over , where :
The antiderivative works because is the derivative (up to the sign) of the exponent. For : , and
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 (). It is a bit less than the standard deviation, because 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 , 1 for the antiderivative and the value, and 0.5 for the step to 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 . The correct call is pnorm(500, 507, 3) = 0.0098, less than 1 %.
Mixing up and . 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 ?”
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).
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 and independent, the difference has standard deviation , 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: , , and the probability is 1 - pnorm(0, 6, sqrt(52)) = 0.7973. With 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.
A bag’s weight is normal with mean 507 g and variance 9. Which command gives P(weight < 500)?
pnorm(500, 507, 3)pnorm(500, 507, 9)1 - pnorm(500, 507, 3)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.
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.
X ~ N(1010, 6) and Y ~ N(1004, 4) are independent. What is the standard deviation of X − Y?
- √(36 + 16) = √52 = 7.21
- 6 − 4 = 2
- 6 + 4 = 10
- √(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.
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.
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).
True or false about the normal?
- In a normal, mean, median and mode coincide.
- The bell’s inflection points are at μ ± σ.
- P(|X − μ| ≤ 2σ) is exactly 0.95.
- 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σ.
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.
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.
To add the variances of X and Y in X − Y or X + Y, what must you be able to say first?
- That X and Y are independent
- That they have the same mean
- That they have the same standard deviation
- That they are positive
Solution
Answer: That X and Y are independent
In the exam, write «independent» before adding variances: it earns marks.
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:
- In Plots, the histogram with the bell; with the Plots arrow go back to the quantile-quantile plot and compare the two.
- Change
qnorm(0.95)toqnorm(0.975): the interval now contains 95 %. How much wider does it get? - Try
pnorm(500, m, var(bags)): it is fragment 1. Compare it withpnorm(500, m, s). - Add
abline(v = 500, lty = 2)after the histogram: the line for the label weight, to the left of all the bars. - Type
?qnormand look forlower.tailin Help.
Cheat sheet: the normal distribution
The essentials in 30 seconds. , with the standard deviation (in R, sd). Symmetric about : mean = median = mode = ; inflection at . , , . Standardise: , . Combinations of independents: means with their sign, variances added.
| I want… | Formula | In R |
|---|---|---|
pnorm(x, mu, sigma) | ||
1 - pnorm(x, mu, sigma) | ||
pnorm(b, …) - pnorm(a, …) | ||
2 * pnorm(c) - 1 | ||
| The value with | qnorm(p, mu, sigma) | |
| The value with | qnorm(1 - p, mu, sigma) | |
| The mean for | L - qnorm(p) * sigma | |
| The for | (L - mu) / qnorm(p) | |
| Simulate | — | rnorm(n, mu, sigma) |
| Check whether data are normal | — | hist(x, freq = FALSE), qqnorm(x); qqline(x) |
| Combination (independent) | Mean | Standard deviation |
|---|---|---|
| and | ||
| Sum of equal | ||
| Mean of equal |
| Quantile | |||||
|---|---|---|---|---|---|
| Value | 1.2816 | 1.6449 | 1.9600 | 2.3263 | 2.5758 |
68-95-99.7 rule: = 0.6827, 0.9545 and 0.9973 for . Others: ; ; ; .
| Symptom | Likely cause |
|---|---|
| An absurd probability (39 % short packets) | The variance in place of sd |
| A quantile on the wrong side of the mean | qnorm(p) instead of qnorm(1 - p) |
integrate(dnorm, -Inf, Inf, mean = 1010, …) gives 0 | Bell far from 0: use finite limits |
The dnorm curve comes out stuck to the histogram axis | freq = FALSE is missing |
| The standard deviation of a difference is smaller than both | Variances were subtracted |
| A mean for “only 1 % below” that is below the limit | The sign of when solving |
Before handing in, ask yourself:
- Have I turned the variance into a standard deviation before using R?
- Have I drawn the tail I am asked for and used
1 -or1 - pwhere needed? - Have I said “independent” before adding variances?
- Do my results have 2 decimals (and 4 for small probabilities) and is the code in the script?
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 , the means and the standard deviations, and it adds the means and takes the square root of the sum of . With a = c(1, -1) it is the difference, and the variances add on their own because . The results match the solutions: 0.23, 0.1336, 47.13, the box with 0.0414, the difference with 0.7973 and the mean of 508.42 g (508.43 in the solution, which uses the unrounded ; 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 and the mgf we have used come from.
Keep goingAll Statistics articlesDid 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)


