ME1 EC1 mock exam — the 4-hour exam with R alongside, four versions, a mark out of 50 and every solution with its code (and why the .R counts too)
The EC1 of Statistical Methods I is not a multiple-choice test, nor just a paper exam: it is 4 hours with your laptop, 4 linked exercises and 50 points, with RStudio open, the data loaded and a .R file you upload to the campus at the end. This mock exam reproduces it: the same 10, 10, 15 and 15 points plus the 2.5-point bonus, the R environment on the right with your version’s data already loaded, boxes that mark themselves to two decimals and criteria to mark your own proofs. When you hand in you see your mark out of 50, which zone it puts you in for passing by coursework, the breakdown part by part, the solution of each part with its R code and the real output, and you can download your script.
There are four original versions: A, B and C follow the 2025-26 EC1 (the same kinds of exercise with other contexts and other data) and D swaps some parts for things that did not come up that year. No statement is real: the data were generated with a script, the answers come from running the solutions’ code once in R, and it has been checked that no data value matches the real exam.
Table of Contents
Take the mock exam
Choose the version and how you want to do it. When you start, the exam fills the window: the statement on the left and R on the right (on a phone, two tabs). The clock shows the 4 hours of the real exam.
The mock exam needs JavaScript. Below you will find what the exam is like and what each exercise covers.
During an exam week I wrote down how long the virtual campus takes to load (in seconds) from the library, in 50 attempts. The data are already in the times vector of your script.
times <- c(1.7, 1.7, 0.9, 3.9, 1.2, 3, 1.5, 1.7, 1.1, 0.3,
3.3, 2.6, 2.1, 1.6, 1, 0.3, 1.7, 2.5, 1.5, 5,
2.2, 0.8, 2.7, 1.1, 1.4, 2.9, 1.7, 5.1, 2.2, 3.1,
0.4, 1.6, 5.5, 2.7, 1.7, 1.8, 0.7, 2.3, 7.4, 6.2,
2.7, 0.5, 1.5, 0.4, 2.9, 5, 1.9, 2, 1.2, 1.2)Use R to find the mean and the median. What does it tell you that they differ?
Solution
- Mean 2.23
- Median 1.70
With R
times <- c(1.7, 1.7, 0.9, 3.9, 1.2, 3, 1.5, 1.7, 1.1, 0.3, 3.3, 2.6, 2.1, 1.6, 1, 0.3, 1.7, 2.5, 1.5, 5, 2.2, 0.8, 2.7, 1.1, 1.4, 2.9, 1.7, 5.1, 2.2, 3.1, 0.4, 1.6, 5.5, 2.7, 1.7, 1.8, 0.7, 2.3, 7.4, 6.2, 2.7, 0.5, 1.5, 0.4, 2.9, 5, 1.9, 2, 1.2, 1.2) mean(times) median(times)
[1] 2.228 [1] 1.7
The mean is 2.23 s and the median 1.70 s. The mean is higher because a few very large values (the long right tail) pull it up; the median does not notice them: the distribution is right-skewed. In the exam, a sentence like this is the «interpretation» they ask for.
Group the data into the classes with limits (0, 1, 2, 4, 6, 10) (closed on the right, as cut does) and give the absolute frequency of the class (2, 4] and the cumulative relative frequency up to 4.
Solution
- count in (2, 4] 15
- F(4) 0.88
With R
classes <- cut(times, breaks = c(0, 1, 2, 4, 6, 10)) freq <- table(classes) freq cumsum(freq) / length(times)
clases
(0,1] (1,2] (2,4] (4,6] (6,10]
9 20 15 4 2
(0,1] (1,2] (2,4] (4,6] (6,10]
0.18 0.58 0.88 0.96 1.00With cut and table you get the frequency table; the cumulative relative one is cumsum(freq) / n. 15 of the 50 values fall in (2, 4], and up to 4 you have 88 % (0.88). Mind the limits: a value equal to 4 goes into (2, 4], not into the next class.
With the grouped table only (not the raw data), find the median with the interpolation formula. Compare it with the one in part a.
Solution
- Grouped median 1.80
With R
n <- sum(freq); Fa <- cumsum(freq) i <- which(Fa >= n / 2)[1] # median class L <- c(0, 1, 2, 4, 6, 10)[i]; a <- diff(c(0, 1, 2, 4, 6, 10))[i] F_prev <- if (i > 1) unname(Fa[i - 1]) else 0 unname(L + (n / 2 - F_prev) / freq[[i]] * a)
[1] 1.8
Half the data is . The first class whose cumulative frequency reaches 25 is the median class: (1, 2], with and . So . It is close to the real median (1.70): grouping assumes the data are spread evenly inside the class. Quick check: the median must fall inside its class; if it does not, you took the wrong .
Let A = «the library wifi goes down», with , and B = «the computer freezes», with , independent. Find the probability that at least one of the two things happens.
Solution
- Probability 0.34
and, being independent, : . The complement gives the same: .
Prove that, if A and B are independent, so are and . Mark yourself with the criteria.
Solution
Marking criteria:
- Writes as a union of two disjoint events 0.5
- Solves 0.5
- Uses independence: 0.5
- Factors out and reaches 0.5
The idea is always the same: split the event into disjoint pieces, solve for the intersection you need and plug in independence. In the exam, write the property you use at each step (disjoint union, De Morgan, complement): that is what earns the marks.
For 40 hours I counted the spam emails that got into my ULPGC inbox (X = spam in an hour). A negative binomial model counting failures is proposed: , , with and (in R, dnbinom(x, size = r, prob = p)). The observed frequencies (already in your script, in the spam vector):
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|---|
| frequency | 5 | 10 | 9 | 3 | 5 | 2 | 2 | 2 | 1 | 1 |
Set up the method of moments (match the model mean and variance to the sample ones) and solve for and in terms of and .
Solution
Marking criteria:
- Sets and 0.5
- Divides one by the other: 0.75
- Substitutes and solves 0.75
Dividing the first equation by the second cancels and : . From the first one, , and with you get . It only makes sense if (overdispersion): otherwise is negative and the model does not fit.
With the data and R, find the estimates of and (use var, the sample variance with n − 1).
Solution
- p̂ 0.50
- r̂ 2.72
With R
spam <- rep(c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), times = c(5, 10, 9, 3, 5, 2, 2, 2, 1, 1)) m <- mean(spam); s2 <- var(spam) p <- m / s2 r <- m^2 / (s2 - m) c(m, s2, p, r)
[1] 2.7500000 5.5256410 0.4976798 2.7245958
, , so and . A non-integer is fine: R accepts a non-integer size.
With the fitted model, find .
Solution
- P(X ≥ 3) 0.45
With R
1 - pnbinom(2, size = r, prob = p) # P(X >= 3)
[1] 0.4549004
«At least 3» is the complement of «2 or fewer»: 1 - pnbinom(2, ...) = 0.45. A typical mistake is 1 - pnbinom(3, ...), which is .
In the Spanish deck (40 cards, 10 per suit: coins, cups, swords and clubs, with 4 kings) 5 cards are dealt without replacement. Probability of at least 2 cups?
Solution
- P 0.37
With R
1 - (choose(30, 5) + choose(10, 1) * choose(30, 4)) / choose(40, 5)
[1] 0.3669439
By the complement of «0 or 1 cups»: (no cups: all 5 from the 30 non-cups; one: 1 of the 10 cups and 4 of the other 30). It is 0.37.
Probability of at least one king?
Solution
- P 0.43
With R
1 - choose(36, 5) / choose(40, 5)
[1] 0.4270708
By the complement: (no king = all 5 from the 36 non-kings). It is 0.43.
X = share of battery my laptop has left after the last class has density for (and 0 elsewhere).
There are three chargers in the classroom: charger 1 is used 40 % of the time and its charging time (in hours) is exponential with mean 2; charger 2, 35 %, uniform between 0 and 4; charger 3, 25 %, gamma with shape 3 and rate 2. T = charging time.
Find so that is a density.
Solution
- c 12
. Also on (0, 1), so it is a density. With R: integrate(f, 0, 1) gives 1.
Find and . Check them with R.
Solution
- E(X) 0.60
- Var(X) 0.04
With R
f <- function(x) 12 * x^2 * (1 - x) integrate(f, 0, 1)$value # 1: it is a density EX <- integrate(function(x) x * f(x), 0, 1)$value EX2 <- integrate(function(x) x^2 * f(x), 0, 1)$value c(EX, EX2 - EX^2)
[1] 1 [1] 0.60 0.04
and ; . They are polynomial integrals: expand the product and integrate term by term. With R, integrate with x * f(x) and x^2 * f(x).
Find and the median of X (with uniroot; the exam asks for rootSolve, which does not exist in the browser).
Solution
- P(X ≤ 0.5) 0.31
- Median 0.61
With R
integrate(f, 0, 0.5)$value # P(X <= 0.5) F <- function(x) integrate(f, 0, x)$value uniroot(function(x) F(x) - 0.5, c(0.01, 0.99))$root # median
[1] 0.3125 [1] 0.6142658
Integrating the density, = 0.31. The median is the with : is a degree 3 or 4 polynomial and the equation cannot be solved by hand, so you look for the root of on (0, 1): . Check: it must be close to the mean (0.60).
Find with total probability.
Solution
- P(T < 1.5) 0.49
With R
t <- 1.5 Pt <- 0.40 * pexp(t, 0.5) + 0.35 * punif(t, 0, 4) + 0.25 * pgamma(t, 3, 2) Pt
[1] 0.4865059
: each term is the weight times its model’s distribution function (pexp, punif, pgamma; careful, in R pexp and pgamma take the rate, not the mean). With t = 1.5 you get 0.49.
If T < 1.5, what is the probability of each charger? Use Bayes.
Solution
- P(charger 1 | T < 1.5) 0.43
- P(charger 2 | T < 1.5) 0.27
- P(charger 3 | T < 1.5) 0.30
With R
c(0.40 * pexp(t, 0.5), 0.35 * punif(t, 0, 4), 0.25 * pgamma(t, 3, 2)) / Pt
[1] 0.4338147 0.2697809 0.2964044
Bayes: each term of the total probability in part d divided by the total 0.49. They are 0.43, 0.27, 0.30; they add up to 1, which is the quick check. Even if a charger is used less, if it is fast it gains weight once you know T was small.
X = number of attempts until I connect to eduroam for the second time in the day, if each attempt succeeds with probability (), has mass function ,
Prove that is a mass function for any value of the parameter.
Solution
Check with R
p <- 0.4; x <- 2:400 fx <- (x - 1) * p^2 * (1 - p)^(x - 2) sum(fx) # 1 t <- 0.1; sum(exp(t * x) * fx) # mgf at t = 0.1 -log(1 - p) # where it exists EX <- sum(x * fx); c(EX, sum(x^2 * fx) - EX^2)
[1] 1 [1] 1.721803 [1] 0.5108256 [1] 5.0 7.5
Marking criteria:
- Takes out and sets : , with 1.5
- Uses (differentiating the geometric series) 2
- Reaches and notes every term is 1.5
Two things: no term is negative and they add up to 1. The sum always reduces to a known series (geometric, its derivative, the exponential or the logarithm): recognising it is the exercise. In R you check it by adding many terms for a specific value of the parameter.
Find the moment generating function of X and where it exists. Check: with p = 0.4, give and the value of t up to which it exists.
Solution
- φ(0.1) 1.72
- largest t 0.51
Result: , for . Put inside the sum, group it with the power already there and you get the same series as in part a with another ratio; that series’ convergence condition is the domain. With p = 0.4: and largest t = 0.51.
Find and (for example, differentiating the mgf at 0). Check: their values with p = 0.4.
Solution
- E(X) 5
- Var(X) 7.50
and ; . With p = 0.4: and . The code in part a checks it with long sums.
If gamma with shape 3 and rate 2, its mgf is , . Use it to find .
Solution
- E(X²) 3
With R
phi <- function(t) (2 / (2 - t))^3 h <- 1e-4 (phi(h) - 2 * phi(0) + phi(-h)) / h^2 # phi''(0) = E(X^2) mean(rgamma(1e6, 3, 2)^2) # simulando: casi lo mismo
[1] 3 [1] 2.999325
, so . Check: .
I timed 50 waits in the cafeteria queue at mid-morning, in minutes. The data are already in the waits vector of your script.
waits <- c(7.6, 3.2, 0.8, 6.2, 5.2, 4.5, 1, 1.8, 1.2, 2.6,
5.4, 4, 5.2, 2.6, 2.6, 4.9, 2.7, 11.6, 3.8, 13.3,
4.4, 3.6, 4.6, 4, 2, 4.2, 10.1, 9.9, 7.2, 5.6,
5.1, 1.5, 3, 4.6, 5, 13.4, 0.6, 1.7, 1.6, 4.4,
10, 8.4, 0.3, 2.2, 10.3, 3.8, 7, 6.7, 12.3, 5.4)Use R to find the mean and the median. What does it tell you that they differ?
Solution
- Mean 5.06
- Median 4.45
With R
waits <- c(7.6, 3.2, 0.8, 6.2, 5.2, 4.5, 1, 1.8, 1.2, 2.6, 5.4, 4, 5.2, 2.6, 2.6, 4.9, 2.7, 11.6, 3.8, 13.3, 4.4, 3.6, 4.6, 4, 2, 4.2, 10.1, 9.9, 7.2, 5.6, 5.1, 1.5, 3, 4.6, 5, 13.4, 0.6, 1.7, 1.6, 4.4, 10, 8.4, 0.3, 2.2, 10.3, 3.8, 7, 6.7, 12.3, 5.4) mean(waits) median(waits)
[1] 5.062 [1] 4.45
The mean is 5.06 min and the median 4.45 min. The mean is higher because a few very large values (the long right tail) pull it up; the median does not notice them: the distribution is right-skewed. In the exam, a sentence like this is the «interpretation» they ask for.
Group the data into the classes with limits (0, 2, 4, 6, 8, 15) (closed on the right, as cut does) and give the absolute frequency of the class (4, 6] and the cumulative relative frequency up to 6.
Solution
- count in (4, 6] 14
- F(6) 0.72
With R
classes <- cut(waits, breaks = c(0, 2, 4, 6, 8, 15)) freq <- table(classes) freq cumsum(freq) / length(waits)
clases
(0,2] (2,4] (4,6] (6,8] (8,15]
10 12 14 5 9
(0,2] (2,4] (4,6] (6,8] (8,15]
0.20 0.44 0.72 0.82 1.00With cut and table you get the frequency table; the cumulative relative one is cumsum(freq) / n. 14 of the 50 values fall in (4, 6], and up to 6 you have 72 % (0.72). Mind the limits: a value equal to 6 goes into (4, 6], not into the next class.
With the grouped table only (not the raw data), find the median with the interpolation formula. Compare it with the one in part a.
Solution
- Grouped median 4.43
With R
n <- sum(freq); Fa <- cumsum(freq) i <- which(Fa >= n / 2)[1] # median class L <- c(0, 2, 4, 6, 8, 15)[i]; a <- diff(c(0, 2, 4, 6, 8, 15))[i] F_prev <- if (i > 1) unname(Fa[i - 1]) else 0 unname(L + (n / 2 - F_prev) / freq[[i]] * a)
[1] 4.428571
Half the data is . The first class whose cumulative frequency reaches 25 is the median class: (4, 6], with and . So . It is close to the real median (4.45): grouping assumes the data are spread evenly inside the class. Quick check: the median must fall inside its class; if it does not, you took the wrong .
Let A = «the omelette sandwiches run out», with , and B = «the queue goes over 10 minutes», with , independent. Find the probability that exactly one of the two things happens.
Solution
- Probability 0.38
«Exactly one» is , two disjoint events: (independence also holds for the complements: that is what part e proves).
Prove that, if A and B are independent, so are and . Mark yourself with the criteria.
Solution
Marking criteria:
- Writes , the two pieces being disjoint 0.5
- Solves 0.5
- Uses the independence of A and B 0.5
- Reaches 0.5
The idea is always the same: split the event into disjoint pieces, solve for the intersection you need and plug in independence. In the exam, write the property you use at each step (disjoint union, De Morgan, complement): that is what earns the marks.
For 40 days I wrote down how many times a day the vending machine in the lecture building swallows the coin and gives nothing (X = failures in a day). A negative binomial model counting failures is proposed: , , with and (in R, dnbinom(x, size = r, prob = p)). The observed frequencies (already in your script, in the fails vector):
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|---|
| frequency | 11 | 6 | 8 | 5 | 3 | 3 | 1 | 2 | 1 |
Set up the method of moments (match the model mean and variance to the sample ones) and solve for and in terms of and .
Solution
Marking criteria:
- Sets and 0.5
- Divides one by the other: 0.75
- Substitutes and solves 0.75
Dividing the first equation by the second cancels and : . From the first one, , and with you get . It only makes sense if (overdispersion): otherwise is negative and the model does not fit.
With the data and R, find the estimates of and (use var, the sample variance with n − 1).
Solution
- p̂ 0.47
- r̂ 2.01
With R
fails <- rep(c(0, 1, 2, 3, 4, 5, 6, 7, 8), times = c(11, 6, 8, 5, 3, 3, 1, 2, 1)) m <- mean(fails); s2 <- var(fails) p <- m / s2 r <- m^2 / (s2 - m) c(m, s2, p, r)
[1] 2.3000000 4.9333333 0.4662162 2.0088608
, , so and . A non-integer is fine: R accepts a non-integer size.
With the fitted model, find .
Solution
- P(X ≤ 1) 0.45
With R
pnbinom(1, size = r, prob = p) # P(X <= 1)
[1] 0.4473941
= pnbinom(1, ...) = 0.45.
A lab box holds 12 USB sticks and 4 are broken. You take 4 at random at once. Probability that exactly 1 is broken?
Solution
- P 0.45
With R
choose(4, 1) * choose(8, 3) / choose(12, 4)
[1] 0.4525253
: one of the 4 broken and three of the 8 good ones. It is 0.45.
Probability that at least 2 are broken?
Solution
- P 0.41
With R
1 - (choose(8, 4) + choose(4, 1) * choose(8, 3)) / choose(12, 4)
[1] 0.4060606
At least 2 = everything except «none» and «exactly 1»: . It is 0.41.
X = share of the day the phone spends in power-saving mode has density for (and 0 elsewhere).
I get to campus three ways: bus (50 % of days; the delay in minutes is exponential with mean 1), car (30 %; delay uniform between 1 and 5) and walking (20 %; delay gamma with shape 2 and rate 0.5). T = delay.
Find so that is a density.
Solution
- c 20
. Also on (0, 1), so it is a density. With R: integrate(f, 0, 1) gives 1.
Find and . Check them with R.
Solution
- E(X) 0.33
- Var(X) 0.03
With R
f <- function(x) 20 * x * (1 - x)^3 integrate(f, 0, 1)$value # 1: it is a density EX <- integrate(function(x) x * f(x), 0, 1)$value EX2 <- integrate(function(x) x^2 * f(x), 0, 1)$value c(EX, EX2 - EX^2)
[1] 1 [1] 0.33333333 0.03174603
and ; . They are polynomial integrals: expand the product and integrate term by term. With R, integrate with x * f(x) and x^2 * f(x).
Find and the median of X (with uniroot; the exam asks for rootSolve, which does not exist in the browser).
Solution
- P(X ≤ 0.2) 0.26
- Median 0.31
With R
integrate(f, 0, 0.2)$value # P(X <= 0.2) F <- function(x) integrate(f, 0, x)$value uniroot(function(x) F(x) - 0.5, c(0.01, 0.99))$root # median
[1] 0.26272 [1] 0.313811
Integrating the density, = 0.26. The median is the with : is a degree 3 or 4 polynomial and the equation cannot be solved by hand, so you look for the root of on (0, 1): . Check: it must be close to the mean (0.33).
Find with total probability.
Solution
- P(T < 2) 0.56
With R
t <- 2 Pt <- 0.50 * pexp(t, 1) + 0.30 * punif(t, 1, 5) + 0.20 * pgamma(t, 2, 0.5) Pt
[1] 0.5601806
: each term is the weight times its model’s distribution function (pexp, punif, pgamma; careful, in R pexp and pgamma take the rate, not the mean). With t = 2 you get 0.56.
If T < 2, what is the probability of each way? Use Bayes.
Solution
- P(way 1 | T < 2) 0.77
- P(way 2 | T < 2) 0.13
- P(way 3 | T < 2) 0.09
With R
c(0.50 * pexp(t, 1), 0.30 * punif(t, 1, 5), 0.20 * pgamma(t, 2, 0.5)) / Pt
[1] 0.77177320 0.13388540 0.09434141
Bayes: each term of the total probability in part d divided by the total 0.56. They are 0.77, 0.13, 0.09; they add up to 1, which is the quick check. Even if a way is used less, if it is fast it gains weight once you know T was small.
X = number of files a classmate uploads each time they open the subject’s shared folder has mass function , , with (logarithmic distribution).
Prove that is a mass function for any value of the parameter.
Solution
Check with R
th <- 0.4; x <- 1:400 fx <- -th^x / (x * log(1 - th)) sum(fx) # 1 t <- 0.2; sum(exp(t * x) * fx) # mgf at t = 0.2 -log(th) # where it exists EX <- sum(x * fx); c(EX, sum(x^2 * fx) - EX^2)
[1] 1 [1] 1.312634 [1] 0.9162907 [1] 1.3050768 0.4719026
Marking criteria:
- Checks every term is (the log of a number below 1 is negative) 1
- Uses the series for 2.5
- Reaches 1.5
Two things: no term is negative and they add up to 1. The sum always reduces to a known series (geometric, its derivative, the exponential or the logarithm): recognising it is the exercise. In R you check it by adding many terms for a specific value of the parameter.
Find the moment generating function of X and where it exists. Check: with θ = 0.4, give and the value of t up to which it exists.
Solution
- φ(0.2) 1.31
- largest t 0.92
Result: , for . Put inside the sum, group it with the power already there and you get the same series as in part a with another ratio; that series’ convergence condition is the domain. With θ = 0.4: and largest t = 0.92.
Find and (for example, differentiating the mgf at 0). Check: their values with θ = 0.4.
Solution
- E(X) 1.31
- Var(X) 0.47
and ; . With θ = 0.4: and . The code in part a checks it with long sums.
If is exponential with rate 4, find using its mgf.
Solution
- E(eˣ) 1.33
With R
4 / (4 - 1) # phi(1) = E(e^X) mean(exp(rexp(1e6, 4))) # simulando
[1] 1.333333 [1] 1.333688
with (valid because ): .
I looked at the length (in seconds) of the last 50 voice notes in the class WhatsApp group. The data are already in the audios vector of your script.
audios <- c(60, 9, 11, 15, 19, 19, 23, 33, 30, 99,
13, 25, 20, 9, 23, 12, 9, 18, 10, 13,
26, 44, 39, 14, 4, 53, 9, 39, 7, 3,
6, 15, 50, 43, 46, 10, 75, 14, 96, 2,
18, 28, 18, 12, 47, 45, 24, 13, 23, 40)Use R to find the mean and the median. What does it tell you that they differ?
Solution
- Mean 26.66
- Median 19
With R
audios <- c(60, 9, 11, 15, 19, 19, 23, 33, 30, 99, 13, 25, 20, 9, 23, 12, 9, 18, 10, 13, 26, 44, 39, 14, 4, 53, 9, 39, 7, 3, 6, 15, 50, 43, 46, 10, 75, 14, 96, 2, 18, 28, 18, 12, 47, 45, 24, 13, 23, 40) mean(audios) median(audios)
[1] 26.66 [1] 19
The mean is 26.66 s and the median 19.00 s. The mean is higher because a few very large values (the long right tail) pull it up; the median does not notice them: the distribution is right-skewed. In the exam, a sentence like this is the «interpretation» they ask for.
Group the data into the classes with limits (0, 10, 20, 40, 60, 120) (closed on the right, as cut does) and give the absolute frequency of the class (20, 40] and the cumulative relative frequency up to 40.
Solution
- count in (20, 40] 12
- F(40) 0.78
With R
classes <- cut(audios, breaks = c(0, 10, 20, 40, 60, 120)) freq <- table(classes) freq cumsum(freq) / length(audios)
clases
(0,10] (10,20] (20,40] (40,60] (60,120]
11 16 12 8 3
(0,10] (10,20] (20,40] (40,60] (60,120]
0.22 0.54 0.78 0.94 1.00With cut and table you get the frequency table; the cumulative relative one is cumsum(freq) / n. 12 of the 50 values fall in (20, 40], and up to 40 you have 78 % (0.78). Mind the limits: a value equal to 40 goes into (20, 40], not into the next class.
With the grouped table only (not the raw data), find the median with the interpolation formula. Compare it with the one in part a.
Solution
- Grouped median 18.75
With R
n <- sum(freq); Fa <- cumsum(freq) i <- which(Fa >= n / 2)[1] # median class L <- c(0, 10, 20, 40, 60, 120)[i]; a <- diff(c(0, 10, 20, 40, 60, 120))[i] F_prev <- if (i > 1) unname(Fa[i - 1]) else 0 unname(L + (n / 2 - F_prev) / freq[[i]] * a)
[1] 18.75
Half the data is . The first class whose cumulative frequency reaches 25 is the median class: (10, 20], with and . So . It is close to the real median (19.00): grouping assumes the data are spread evenly inside the class. Quick check: the median must fall inside its class; if it does not, you took the wrong .
Let A = «a voice note is longer than a minute», with , and B = «the class rep sends it», with , independent. Find the probability that a voice note is longer than a minute and is not sent by the class rep.
Solution
- Probability 0.30
, which is : if A and B are independent, so are A and .
Prove that, if A and B are independent, so are and . Mark yourself with the criteria.
Solution
Marking criteria:
- Uses De Morgan: 0.5
- 0.5
- Uses independence: 0.5
- Factorises: 0.5
The idea is always the same: split the event into disjoint pieces, solve for the intersection you need and plug in independence. In the exam, write the property you use at each step (disjoint union, De Morgan, complement): that is what earns the marks.
In the IS project I counted, over 40 work sessions, how many commits broke the build (X = failed commits in a session). A negative binomial model counting failures is proposed: , , with and (in R, dnbinom(x, size = r, prob = p)). The observed frequencies (already in your script, in the commits vector):
| x | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| frequency | 15 | 13 | 8 | 1 | 2 | 1 |
Set up the method of moments (match the model mean and variance to the sample ones) and solve for and in terms of and .
Solution
Marking criteria:
- Sets and 0.5
- Divides one by the other: 0.75
- Substitutes and solves 0.75
Dividing the first equation by the second cancels and : . From the first one, , and with you get . It only makes sense if (overdispersion): otherwise is negative and the model does not fit.
With the data and R, find the estimates of and (use var, the sample variance with n − 1).
Solution
- p̂ 0.73
- r̂ 2.99
With R
commits <- rep(c(0, 1, 2, 3, 4, 5), times = c(15, 13, 8, 1, 2, 1)) m <- mean(commits); s2 <- var(commits) p <- m / s2 r <- m^2 / (s2 - m) c(m, s2, p, r)
[1] 1.1250000 1.5480769 0.7267081 2.9914773
, , so and . A non-integer is fine: R accepts a non-integer size.
With the fitted model, find .
Solution
- P(X = 0) 0.38
With R
dnbinom(0, size = r, prob = p) # P(X = 0)
[1] 0.3848235
= dnbinom(0, ...) = 0.38: a bit over a third of the sessions break nothing.
For the project defence, a panel of 5 students is drawn from 14 volunteers: 6 from GCID and 8 from other degrees. Probability of exactly 2 from GCID?
Solution
- P 0.42
With R
choose(6, 2) * choose(8, 3) / choose(14, 5)
[1] 0.4195804
. It is 0.42.
Probability that GCID has a majority (3 or more)?
Solution
- P 0.34
With R
sum(choose(6, 3:5) * choose(8, 2:0)) / choose(14, 5)
[1] 0.3426573
Add the cases 3, 4 and 5: . It is 0.34.
X = share of the practice server memory in use at the end of the day has density for (and 0 elsewhere).
Build jobs go to three servers: server 1 gets 25 % and takes (in minutes) an exponential with mean 4; server 2, 45 %, uniform between 0 and 8; server 3, 30 %, gamma with shape 4 and rate 2. T = build time.
Find so that is a density.
Solution
- c 1.20
. Also on (0, 1), so it is a density. With R: integrate(f, 0, 1) gives 1.
Find and . Check them with R.
Solution
- E(X) 0.70
- Var(X) 0.05
With R
f <- function(x) 1.2 * (x + x^2) integrate(f, 0, 1)$value # 1: it is a density EX <- integrate(function(x) x * f(x), 0, 1)$value EX2 <- integrate(function(x) x^2 * f(x), 0, 1)$value c(EX, EX2 - EX^2)
[1] 1 [1] 0.70 0.05
and ; . They are polynomial integrals: expand the product and integrate term by term. With R, integrate with x * f(x) and x^2 * f(x).
Find and the median of X (with uniroot; the exam asks for rootSolve, which does not exist in the browser).
Solution
- P(X ≤ 0.5) 0.20
- Median 0.75
With R
integrate(f, 0, 0.5)$value # P(X <= 0.5) F <- function(x) integrate(f, 0, x)$value uniroot(function(x) F(x) - 0.5, c(0.01, 0.99))$root # median
[1] 0.2 [1] 0.7460153
Integrating the density, = 0.20. The median is the with : is a degree 3 or 4 polynomial and the equation cannot be solved by hand, so you look for the root of on (0, 1): . Check: it must be close to the mean (0.70).
Find with total probability.
Solution
- P(T < 3) 0.56
With R
t <- 3 Pt <- 0.25 * pexp(t, 0.25) + 0.45 * punif(t, 0, 8) + 0.30 * pgamma(t, 4, 2) Pt
[1] 0.5552972
: each term is the weight times its model’s distribution function (pexp, punif, pgamma; careful, in R pexp and pgamma take the rate, not the mean). With t = 3 you get 0.56.
If T < 3, what is the probability of each server? Use Bayes.
Solution
- P(server 1 | T < 3) 0.24
- P(server 2 | T < 3) 0.30
- P(server 3 | T < 3) 0.46
With R
c(0.25 * pexp(t, 0.25), 0.45 * punif(t, 0, 8), 0.30 * pgamma(t, 4, 2)) / Pt
[1] 0.2375455 0.3038913 0.4585632
Bayes: each term of the total probability in part d divided by the total 0.56. They are 0.24, 0.30, 0.46; they add up to 1, which is the quick check. Even if a server is used less, if it is fast it gains weight once you know T was small.
X = number of times I compile a lab exercise until it passes: the first one plus a number of retries that follows a Poisson with mean . Its mass function is ,
Prove that is a mass function for any value of the parameter.
Solution
Check with R
la <- 2; x <- 1:100 fx <- dpois(x - 1, la) sum(fx) # 1 t <- 0.1; sum(exp(t * x) * fx) # mgf at t = 0.1 fx[3] # P(X = 3) EX <- sum(x * fx); c(EX, sum(x^2 * fx) - EX^2)
[1] 1 [1] 1.363891 [1] 0.2706706 [1] 3 2
Marking criteria:
- Sets and takes out 1.5
- Recognises 2
- Reaches 1 and notes every term is 1.5
Two things: no term is negative and they add up to 1. The sum always reduces to a known series (geometric, its derivative, the exponential or the logarithm): recognising it is the exercise. In R you check it by adding many terms for a specific value of the parameter.
Find the moment generating function of X and where it exists. Check: with λ = 2, give and P(X = 3) (from the mass).
Solution
- φ(0.1) 1.36
- P(X = 3) 0.27
Result: , for every . Put inside the sum, group it with the power already there and you get the same series as in part a with another ratio; that series’ convergence condition is the domain. With λ = 2: and P(X = 3) = 0.27.
Find and (for example, differentiating the mgf at 0). Check: their values with λ = 2.
Solution
- E(X) 3
- Var(X) 2
and ; . With λ = 2: and . The code in part a checks it with long sums.
If is uniform on (0, 2), find using its mgf.
Solution
- E(eˣ) 3.19
With R
(exp(2) - 1) / 2 # phi(1) = E(e^X) mean(exp(runif(1e6, 0, 2))) # simulando
[1] 3.194528 [1] 3.193795
The mgf of the uniform on (0, 2) is ; .
The marks (out of 10) of the 50 students who sat a first-year midterm. The data are already in the marks vector of your script.
marks <- c(7.1, 3.5, 7.1, 0.8, 6.7, 7.1, 5.3, 7.5, 2.7, 6.3,
4.7, 3.3, 5.5, 5.5, 6.7, 5.8, 6.9, 1.2, 7.3, 9.2,
7.4, 4.9, 3.6, 8.6, 3, 3, 4.5, 7.8, 4.8, 7.8,
5.2, 7.5, 6.2, 3.3, 6, 6.3, 6, 5.8, 6.2, 7.4,
10, 9.7, 7, 6.4, 5.1, 4.9, 5.3, 7.9, 7.1, 8.1)Use R to find the first and third quartiles (those of quantile, type 7).
Solution
- Q1 4.90
- Q3 7.25
With R
marks <- c(7.1, 3.5, 7.1, 0.8, 6.7, 7.1, 5.3, 7.5, 2.7, 6.3, 4.7, 3.3, 5.5, 5.5, 6.7, 5.8, 6.9, 1.2, 7.3, 9.2, 7.4, 4.9, 3.6, 8.6, 3, 3, 4.5, 7.8, 4.8, 7.8, 5.2, 7.5, 6.2, 3.3, 6, 6.3, 6, 5.8, 6.2, 7.4, 10, 9.7, 7, 6.4, 5.1, 4.9, 5.3, 7.9, 7.1, 8.1) quantile(marks, c(0.25, 0.75))
25% 75% 4.90 7.25
25 % of the marks are below 4.90 and 75 % below 7.25: the middle half of the class got between 4.90 and 7.25.
Find the interquartile range and how many marks are outliers with the 1.5 × IQR rule (the one boxplot uses).
Solution
- IQR 2.35
- Outliers 2
With R
q <- quantile(marks, c(0.25, 0.75)); IQRm <- IQR(marks) IQRm sum(marks < q[1] - 1.5 * IQRm | marks > q[2] + 1.5 * IQRm) # outliers boxplot(marks, horizontal = TRUE)
[1] 2.35 [1] 2
IQR = Q3 − Q1 = 2.35. The whiskers reach at most Q1 − 1.5·IQR = 1.38 and Q3 + 1.5·IQR = 10.78: 2 marks are outside, the two very low ones (the 10 is not: it just gets in). In the boxplot they show up as single points on the left.
Find the coefficient of variation (sd divided by the mean) and say whether the mean is representative.
Solution
- CV 0.34
With R
sd(marks) / mean(marks)
[1] 0.336305
CV = s / x̄ = 0.34: the standard deviation is 34 % of the mean. Below 0.5 the mean is usually taken as representative, although the two outliers pull it down a little.
A plagiarism checker flags 90 % of copied essays and 5 % of original ones as «suspicious». If 8 % of essays are copied, what proportion of essays does it flag?
Solution
- P(+) 0.12
Total probability with the tree: .
If an essay is flagged, what is the probability that it is copied? Interpret the result.
Solution
- P(C | +) 0.61
Bayes: . Although the checker catches 90 % of copies, almost four in ten flagged essays are original: there are so many originals that their false positives matter.
For 40 class hours I counted the incidents reported to IT support from the lecture building (X = incidents in an hour). A Poisson model with parameter is proposed. The frequencies (already in your script, in the calls vector):
| x | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| frequency | 5 | 6 | 12 | 10 | 5 | 2 |
Prove that, if , , and derive the method-of-moments estimator of .
Solution
Marking criteria:
- Writes and drops the term 0.5
- Simplifies and takes out 0.5
- Recognises the series of and reaches 0.5
- Sets : 0.5
. One parameter, one equation: .
Find and the sample variance. Does the Poisson fit?
Solution
- λ̂ 2.25
- s² 1.83
With R
calls <- rep(c(0, 1, 2, 3, 4, 5), times = c(5, 6, 12, 10, 5, 2)) lambda <- mean(calls) c(lambda, var(calls))
[1] 2.250000 1.833333
and . In a Poisson the mean and the variance match; here they are close, so the model is reasonable (if the variance were much bigger you would think of a negative binomial).
With the fitted model, find the probability of 4 or more incidents in an hour.
Solution
- P(X ≥ 4) 0.19
With R
1 - ppois(3, lambda) # P(X >= 4)
[1] 0.1905669
1 - ppois(3, lambda) = 0.19: almost one hour in five.
There are 8 group presentations in the last class and the order is drawn. Three of them are from your group of friends. Probability that your three go one after the other?
Solution
- P 0.11
With R
factorial(3) * factorial(6) / factorial(8)
[1] 0.1071429
The three together are one block: you order 6 items () and the 3 inside the block (), over : . It is 0.11.
Probability that you go first and Laura goes last?
Solution
- P 0.02
With R
factorial(6) / factorial(8)
[1] 0.01785714
With first and last fixed, the other 6 can go in any order: . It is 0.02.
X = relative humidity of the lab (as a fraction) first thing in the morning has density for (and 0 elsewhere).
Humidity is measured by two sensors: sensor 1 gives 60 % of the readings and its response time (in seconds) is exponential with rate 2; sensor 2, 40 %, uniform between 0 and 1.5. T = response time.
Find so that is a density, and the mode of X.
Solution
- c 12
- Mode 0.33
. For the mode: (at the density is 0). It is a beta(2, 3).
Find and . Check them with R.
Solution
- E(X) 0.40
- Var(X) 0.04
With R
f <- function(x) 12 * x * (1 - x)^2 integrate(f, 0, 1)$value # 1: it is a density EX <- integrate(function(x) x * f(x), 0, 1)$value EX2 <- integrate(function(x) x^2 * f(x), 0, 1)$value c(EX, EX2 - EX^2)
[1] 1 [1] 0.40 0.04
and ; . They are polynomial integrals: expand the product and integrate term by term. With R, integrate with x * f(x) and x^2 * f(x).
Find and the median of X (with uniroot; the exam asks for rootSolve, which does not exist in the browser).
Solution
- P(X > 0.5) 0.31
- Median 0.39
With R
integrate(f, 0.5, 1)$value # P(X > 0.5) F <- function(x) integrate(f, 0, x)$value uniroot(function(x) F(x) - 0.5, c(0.01, 0.99))$root # median
[1] 0.3125 [1] 0.3857342
Integrating the density, = 0.31. The median is the with : is a degree 3 or 4 polynomial and the equation cannot be solved by hand, so you look for the root of on (0, 1): . Check: it must be close to the mean (0.40).
Find with total probability.
Solution
- P(T < 0.5) 0.51
With R
t <- 0.5 Pt <- 0.60 * pexp(t, 2) + 0.40 * punif(t, 0, 1.5) Pt
[1] 0.5126057
: each term is the weight times its model’s distribution function (pexp, punif, pgamma; careful, in R pexp and pgamma take the rate, not the mean). With t = 0.5 you get 0.51.
If T < 0.5, what is the probability of each sensor? Use Bayes.
Solution
- P(sensor 1 | T < 0.5) 0.74
- P(sensor 2 | T < 0.5) 0.26
With R
c(0.60 * pexp(t, 2), 0.40 * punif(t, 0, 1.5)) / Pt
[1] 0.739891 0.260109
Bayes: each term of the total probability in part d divided by the total 0.51. They are 0.74, 0.26; they add up to 1, which is the quick check. Even if a sensor is used less, if it is fast it gains weight once you know T was small.
X = number of new virtual campus notifications when I log in and there is at least one: a Poisson with mean with the 0 removed. Its mass function is ,
Prove that is a mass function for any value of the parameter.
Solution
Check with R
la <- 1.5; x <- 1:100 fx <- dpois(x, la) / (1 - exp(-la)) sum(fx) # 1 t <- 0.1; sum(exp(t * x) * fx) # mgf at t = 0.1 fx[1] # P(X = 1) EX <- sum(x * fx); c(EX, sum(x^2 * fx) - EX^2)
[1] 1 [1] 1.219961 [1] 0.4308254 [1] 1.930825 1.098977
Marking criteria:
- Writes (the exponential series without the 0 term) 2.5
- Simplifies 1.5
- Notes every term is 1
Two things: no term is negative and they add up to 1. The sum always reduces to a known series (geometric, its derivative, the exponential or the logarithm): recognising it is the exercise. In R you check it by adding many terms for a specific value of the parameter.
Find the moment generating function of X and where it exists. Check: with λ = 1.5, give and P(X = 1) (from the mass).
Solution
- φ(0.1) 1.22
- P(X = 1) 0.43
Result: , for every . Put inside the sum, group it with the power already there and you get the same series as in part a with another ratio; that series’ convergence condition is the domain. With λ = 1.5: and P(X = 1) = 0.43.
Find and (for example, differentiating the mgf at 0). Check: their values with λ = 1.5.
Solution
- E(X) 1.93
- Var(X) 1.10
and ; . With λ = 1.5: and . The code in part a checks it with long sums.
If , its mgf is . Use it to find .
Solution
- E(X²) 2.28
With R
phi <- function(t) (0.7 + 0.3 * exp(t))^4 h <- 1e-4 (phi(h) - 2 * phi(0) + phi(-h)) / h^2 # phi''(0) = E(X^2) mean(rbinom(1e6, 4, 0.3)^2) # simulando
[1] 2.28 [1] 2.276679
. Check: .
If you choose On paper, click «Download the exam paper (PDF)»: you get your version’s PDF, ready to print, with the cover page, the empty marks table and the boxes of each part, without solutions. R stays beside you for whatever needs it, as in the classroom. It is the best way to train for the real exam, because the working counts too.
version D is a rotation: exercise 1 becomes quartiles, outliers and Bayes with a tree; exercise 2, the Poisson and ordering with factorials; exercise 3, a beta with its mode and a two-component mixture; and exercise 4, a Poisson without the zero. They are EC1 syllabus topics that did not come up in 2025-26.
What the ME1 EC1 is like
It is sat in the classroom, on your own laptop (RStudio installed and the battery at 100 %) inside the exam’s secure browser, with the data files and RStudio open. It lasts 4 hours and is worth 50 points, half of the subject mark. There are 4 exercises, each with its own context and several parts that build on each other: one part often needs the result of the one before. Some are done by hand (calculations and proofs) and others with R, and every result is given with two decimals. There is also a bonus that adds on top.
| Exercise | What is asked | Topics | Points |
|---|---|---|---|
| 1 | Some data to describe (mean, median, frequency table with cut, grouped median) and two independent events | 1 and 2 | 10 |
| 2 | A discrete model fitted by the method of moments, a probability with it and two counting ones | 2 and 3 | 10 |
| 3 | A density with a constant (moments, distribution function and median with R) and a mixture of three models with total probability and Bayes | 4 (and 2) | 15 |
| 4 | A mass function with a parameter: that it is a mass function, its mgf and the mean | 3 | 15 |
| Bonus | Using a known mgf to get a moment or an expectation | 3 and 4 | +2.5 |
Look at the diagram: exercise 4 is all on paper and is worth as much as exercise 3, and almost half the parts of exercises 1 to 3 are done with R. That is why the EC1 rewards two things at once: knowing the standard proofs and moving fast in R.
What you can bring: the cheat sheet and your .R
You go into the EC1 with two things of your own:
- A handwritten cheat sheet, one sheet, both sides. Results are allowed (formulas, means, variances, the mgf of the models), but not proofs. The cheat sheet at the end of this article is a good base for yours.
- A single
.Rfile you upload to the campus before a deadline, with your code from the classes and the labs. In the exam you have it open in RStudio. The «For your script» section of each topic’s exercises has that topic’s code already commented.
And at the end, you upload the .R with the code of each exercise. Without it, that exercise is not marked, even if the results are right. In the mock exam, the script on the right plays that role: when you hand in you can download it.
Leaving the code in the console instead of the script. What you type in RStudio’s console is not saved in the .R: write in the script and run with Ctrl + Enter, as in the mock exam.
How it is marked
Each part is a box of the marks table (1.a, 1.b… 4.c and the bonus). There are two kinds:
- Parts with a result. You write it in its boxes and it is marked automatically, with a 0.01 tolerance (comma or point both work). If the part has two boxes, each is worth half.
- Proofs. There is no number to check, so when you hand in you get the criteria with their points (for example, «sets up the two equations», «solves for p», «solves for r») and you tick the ones you did. It is how the lecturer marks: step by step.
The parts that need working in the exam have the «I worked it out on paper» box. Unticked they are worth 0 even if the result is right, with a note of how much you would have: in the real exam, a number with no working does not score. The ones done only with R do not have it, because their «working» is the code in the .R.
The mark is out of 50, with the bonus on top, and the mock exam tells you which zone you are in with the rules of the 2026/27 course guide: with 25 or more the EC is passed and kept for the final and the resit; with over 20 it counts towards passing by coursework if EC1 and EC2 add up to 50; with 20 or less you cannot pass by coursework. The subject mark is (EC1 + EC2) / 10, plus the extra from the virtual classroom quizzes and the bonuses, and the ME1 calculator tells you what you need in EC2 with the mark you get here.
The four versions
| Version | Exercise 1 | Exercise 2 | Exercise 3 | Exercise 4 |
|---|---|---|---|---|
| A | The library wifi: loading times; P(A ∪ B) | Spam per hour (negative binomial); the Spanish deck | The laptop battery and three chargers | Attempts until the second eduroam connection |
| B | The cafeteria queue; «exactly one» | The vending machine; broken USB sticks | Power-saving mode and three ways to campus | Files in the shared folder (logarithmic) |
| C | The class group voice notes; P(A ∩ Bᶜ) | Failed commits; the project panel | The server memory and three build servers | Attempts with the compiler (shifted Poisson) |
| D | Midterm marks: quartiles and outliers; the plagiarism checker (Bayes) | Incidents per hour (Poisson); the presentation order | The lab humidity (beta) and two sensors | Virtual campus notifications (Poisson without the zero) |
In each version the bonus uses a different mgf: a gamma, an exponential, a uniform and a binomial.
How the mock exam works
Choose version and mode. «On screen» shows the parts with their boxes from the start. «On paper» hides them while you do the exam by hand and lets you download the blank exam as a PDF.
R is on your right. It is the site’s R environment (R 4.6 in the browser, with RStudio’s panes): the script ec1-A.R (or your version’s) already has the data for exercises 1 and 2 in their vectors and a gap under each exercise. Ctrl + Enter runs the line and Ctrl + Shift + Enter runs everything. The first time R takes a few seconds to load; after that it is instant. The splitter in the middle can be dragged to give more room to the statement or to R, and on a phone you switch between «Exam» and «R» with the tabs at the top.
The exam asks for the rootSolve package to find the median; it does not exist in the browser, so here we use uniroot, which comes with R and does the same for one root. In RStudio you can use either.
Hand in. The button asks for confirmation if you leave parts out. You see your mark out of 50, the marks table, the zone you land in, the proof criteria to tick and, in each part, the worked solution with its R code and real output, your mistakes marked and a «Review this topic» link. With «Download my .R script» you keep what you wrote.
Nothing is stored on any server: if you reload the page, you start from scratch. You can repeat each version as many times as you like, but the second time it no longer measures the same thing.
How to split the 4 hours
With 240 minutes and 50 points you get about 4.5 minutes per point, but parts do not all cost the same: the R ones are quick if you have the code at hand and the proofs in exercise 4 are slow. A split that works, leaving half an hour to check:
| Block | Points | Minutes | Why |
|---|---|---|---|
| Exercise 1 | 10 | 35 | mean, median, cut and table are quick; the grouped median, with the formula |
| Exercise 2 | 10 | 40 | Solve the moments on paper and then everything in R; counting with choose |
| Exercise 3 | 15 | 60 | Polynomial integrals by hand, checked with integrate; the mixture with pexp, punif and pgamma |
| Exercise 4 | 15 | 60 | Recognising the series is half the exercise; the mgf comes out of the same series |
| Bonus | 2.5 | 15 | Only if you have time left: a derivative of the mgf or evaluating it at 1 |
| Check and upload the .R | — | 30 | Check the two decimals, that the script runs all the way and save it |
35 + 40 + 60 + 60 + 15 + 30 = 240 minutes. If a part gets stuck, write down the value you were missing as an assumption («if p = 0.5…») and move on: many parts can be solved with an assumed value.
What it covers: exercise by exercise
Each exercise matches one or two ME1 topics on the site. The exam-style exercises of each topic have parts in the same format and their cheat sheet.
| Exercise | Topic | Theory | Proofs | Exercises |
|---|---|---|---|---|
| 1 | Descriptive statistics | Theory | Proofs | Exercises |
| 1 and 2 | Probability: counting, conditional and Bayes | Theory | Proofs | Exercises |
| 2 and 4 | Discrete random variables | Theory | Proofs | Exercises |
| 3 | Continuous random variables | Theory | Proofs | Exercises |
The normal distribution is not in EC1: it opens EC2.
Typical mistakes in the EC1
- Giving more or fewer than two decimals. The statement asks for it and it is the first thing that gets checked.
round(x, 2)at the end, not in the intermediate steps. - Closing the classes wrongly.
cutcloses on the right: a value equal to a limit goes into the class on the left, (2, 4] and not (4, 6]. - Picking the wrong median class. It is the first one whose cumulative frequency reaches n/2; if the grouped median falls outside its class, is wrong.
- Using the mean instead of the rate in R.
pexp(t, rate)andpgamma(t, shape, rate)take the rate; an exponential with mean 2 ispexp(t, 0.5). - Counting successes where R counts failures.
dnbinomcounts the failures before the r-th success; if your model counts attempts, subtract. - «At least k» with the wrong cumulative. , that is,
1 - pnbinom(2, ...), not1 - pnbinom(3, ...). - Proving it is a mass function but forgetting it is not negative. Two things: every term is and they add up to 1.
- The mgf without its domain. An mgf without «for » is incomplete: it comes from the series’ convergence condition.
- The code in the console. Whatever is not in the
.Rdoes not exist for marking.
Cheat sheet: what you can bring on your sheet
The essentials in 30 seconds: the mean and the median describe the center and, if they differ, the distribution is skewed; the grouped median is ; with A and B independent, and so are their complements; the method of moments matches the mean and the variance to the sample ones; a density integrates to 1 and its median solves ; total probability and Bayes split by components; and the mgf gives the moments by differentiating at 0.
| I want to… | How | In R |
|---|---|---|
| Mean, median, quartiles | ; the median leaves half on each side | mean(x), median(x), quantile(x, c(0.25, 0.75)) |
| Sample variance | var(x), sd(x) | |
| Frequency table | Classes (a, b], absolute and cumulative relative | table(cut(x, breaks)), cumsum(f) / n |
| Grouped median | — | |
| Outliers | Outside | IQR(x), boxplot(x) |
| Union | — | |
| Independence | , and with , | — |
| Total probability and Bayes | ; | — |
| Counting without order | choose(n, k), factorial(n) | |
| Negative binomial (failures) | , | dnbinom(x, size = r, prob = p) |
| Moments with the NB | , | — |
| Poisson | , | dpois, ppois |
| Density | , , | integrate(f, 0, 1) |
| Median of a continuous one | uniroot(function(x) F(x) - 0.5, c(a, b)) | |
| Exponential and gamma | ; gamma(a, b): , , | pexp(t, rate), pgamma(t, shape, rate) |
| Uniform (a, b) | , | punif(t, a, b) |
| Moments from the mgf | , , | — |
| Series for mass functions | , , , | — |
What to revise on the site
If a part comes out red, the «Review this topic» link in its solution takes you to the exercises (or the proofs) of the topic that explains it. Before trying again with another version:
- The exam-style exercises of the four topics: they have parts with points, like these, and their «For your script».
- The proofs of topics 2, 3 and 4: the independence of complements, the moments of the discrete models, the mgf and the mixture.
- The R playground to practice with your own script with nothing to install.
- The ME1 calculator, to know what you need in EC2.
Summary
| What | What it is like |
|---|---|
| Time and points | 4 hours, 50 points (10 + 10 + 15 + 15) and a 2.5-point bonus |
| Materials | Laptop with RStudio, one handwritten cheat sheet and your .R; at the end you upload the exam’s .R |
| Marking in the mock exam | Boxes to two decimals (0.01 tolerance), criteria for the proofs, «I worked it out on paper» |
| What the mark means | 25 or more: passed and kept; over 20: counts if you reach 50 with EC2; 20 or less: to the final |
| Versions | A, B and C as in 2025-26; D with what did not come up |
Three ideas for exam day: all the code in the script, because what is not in the .R is not marked; two decimals at the end, not at every step; and in exercise 4, look for the series: once you recognise it, the mass function, the mgf and the mean almost come out by themselves.
Did this article help you? Here is how you can support SergioLearns →



