ME1 final exam mock — the part you are missing or the whole subject, with R beside you, four versions of each format (and how to know which one you sit)
The Statistical Methods I final is not one exam but three: if you passed one of the two continuous assessments, you only retake the other half (part 1 or part 2, 3 hours and 50 points), and if you passed neither, you sit the whole subject (4 hours and 100 points). This mock exam reproduces the three formats of the 2025-26 finals: the same linked exercises and the same points, the R environment on the right with your version’s data already loaded, boxes that mark themselves with two decimals and criteria to mark your own proofs. When you hand in you see your mark (out of 50 or out of 100), whether it is enough, the breakdown part by part and the solution of each one with its R code and the real output.
Each format has four original versions: A, B and C follow the 2025-26 finals (the same kinds of exercise with other contexts and other data) and D swaps some parts for syllabus topics 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 with R and it was checked that no data match the real exams.
Table of Contents
Take the mock exam
Choose the format, the version and how you want to do it. When you start, the exam fills the whole window: the statement on the left and R on the right (on a phone, two tabs). The clock shows the 3 hours of each part or the 4 of the whole subject.
The mock exam needs JavaScript. Below you will find what the exam is like and what each exercise covers.
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Let A = «the order arrives late» and B = «a product is missing» be two independent events, with and . Find from A and B and compare it with . Are and independent?
Solution
- P(Aᶜ ∩ Bᶜ) 0.77
- P(Aᶜ)·P(Bᶜ) 0.77
- Independent? Yes
With R
pa <- 0.15; pb <- 0.1 1 - (pa + pb - pa * pb) # P(Ac ∩ Bc) = 1 - P(A ∪ B) (1 - pa) * (1 - pb) # the product of their probabilities
[1] 0.765 [1] 0.765
By De Morgan, , and . They match, so they are independent: it is not a coincidence of these numbers, it is what you prove in the next part.
Prove that, if A and B are independent, so are and . Mark yourself with the criteria.
Solution
Marking criteria:
- Uses De Morgan: 0.75
- Writes 0.75
- Uses independence: 0.75
- Factorises: 0.75
The idea is always the same: split the event into disjoint pieces (or go to the complement with De Morgan), solve for the intersection you need and plug in independence. In the exam, write the property you use at each step: that is what earns the marks.
Let X be the fraction of the battery a rider’s phone uses in one shift, a continuous variable on (0, 1) with density for (and 0 elsewhere). Find K so that f is a density.
Solution
- K 20
With R
g <- function(x) x^3 * (1 - x) # the density without K K <- 1 / integrate(g, 0, 1)$value K
[1] 20
, so (20.0000 as a decimal). A density cannot be negative anywhere, and here it is not.
Find the mean and the variance of X.
Solution
- E(X) 0.67
- Var(X) 0.03
With R
f <- function(x) K * g(x) EX <- integrate(function(x) x * f(x), 0, 1)$value VX <- integrate(function(x) x^2 * f(x), 0, 1)$value - EX^2 c(EX, VX)
[1] 0.66666667 0.03174603
and , so . With two decimals: 0.67 and 0.03.
Find the distribution function of X. Check: .
Solution
- F(0.5) 0.19
With R
F <- function(x) integrate(f, 0, x)$value F(0.5)
[1] 0.1875
For , ; if and if . At the check point, .
Using R’s curve function, plot the density f. Mark yourself with the criteria.
Solution
With R
curve(f, 0, 1, lwd = 2, ylab = "f(x)") abline(v = EX, lty = 2) # the mean, to place it
Marking criteria:
- Defines f in R with K and vectorised (it accepts a vector x) 0.5
- Calls
curve(f, 0, 1)(or withfromandto) 0.5 - Describes the shape: rises slowly, peaks at and drops sharply to 0 at 0.5
- Places the mean (and the median of the next part) on the plot 0.5
The curve you should get: rises slowly, peaks at and drops sharply to 0 at . If curve gives a length error, f is not vectorised: with integrate inside it would not be, which is why f is defined with the formula and not with integrals.
With R, find the median of X (for example with uniroot, or with uniroot.all from the rootSolve library).
Solution
- Median 0.69
With R
uniroot(function(x) F(x) - 0.5, c(0.001, 0.999))$root # median: F(x) = 0.5
[1] 0.6861859
The median is the x with : 0.69. It is above the mean, because the long tail is on the left.
A supermarket delivers with three vans. The time T (in minutes) an order takes depends on the van: «Van 1» handles 45% and its time is exponential with mean 20; «Van 2» handles 35% and its time is uniform between 10 and 40; «Van 3» handles 20% and its time is gamma with shape 4 and rate 0.2 (mean 20). Find the probability that an order arrives in 25 minutes or less, .
Solution
- P(T ≤ 25) 0.64
With R
t <- 25
P <- c(0.45 * pexp(t, 1/20),
0.35 * punif(t, 10, 40),
0.2 * pgamma(t, 4, 0.2))
sum(P) # P(T <= 25)[1] 0.6430677
By total probability: , each conditional probability coming from its model. It gives 0.64.
Given that an order arrives in 25 minutes or less, use R to find the probability that each one handled it.
Solution
- Van 1 0.50
- Van 2 0.27
- Van 3 0.23
With R
P / sum(P) # P(source | T <= 25)
[1] 0.4992831 0.2721331 0.2285838
Bayes: ; each term of the previous part over the total. You get 0.50, 0.27, 0.23, which add up to 1.
It has 2 independent parts (2.1, 2.2…); within each one, a part often needs the one before.
Data for part 2.1.a:
complaints <- c(0, 1, 0, 2, 3, 0, 1, 3, 0, 0,
2, 0, 2, 0, 0, 2, 1, 4, 1, 0,
0, 1, 0, 1, 0, 0, 3, 0, 5, 0)X is the number of complaints the supermarket’s customer service receives per day. It is assumed to follow a geometric (number of failures before the first success), with and . The data for 30 days are in the complaints vector of your script.
Two ways to estimate : (1) set the model mean equal to the sample mean and (2) set the model variance equal to the sample variance. With R, find by both methods and compare them.
Solution
- Method 1 0.48
- Method 2 0.51
With R
complaints <- c(0, 1, 0, 2, 3, 0, 1, 3, 0, 0,
2, 0, 2, 0, 0, 2, 1, 4, 1, 0,
0, 1, 0, 1, 0, 0, 3, 0, 5, 0)
x <- complaints; m <- mean(x); s2 <- var(x)
p1 <- 1 / (1 + m) # mean: (1 - p)/p = sample mean
p2 <- (-1 + sqrt(1 + 4 * s2)) / (2 * s2) # variance: (1 - p)/p^2 = sample variance
c(m, s2, p1, p2)[1] 1.0666667 1.9264368 0.4838710 0.5062586
Sample mean 1.07 and sample variance 1.93. (1) gives . (2) is the quadratic , whose positive root is . If the model were perfect, the two would be very close; the further apart they are, the more suspicious the model.
With R and for each method, find the probability of exactly one complaint, , and of between 2 and 4, .
Solution
- P(X = 1), meth. 1 0.25
- P(2 ≤ X ≤ 4), meth. 1 0.23
- P(X = 1), meth. 2 0.25
- P(2 ≤ X ≤ 4), meth. 2 0.21
With R
c(dgeom(1, p1), pgeom(4, p1) - pgeom(1, p1)) # method 1: P(X = 1), P(2 <= X <= 4) c(dgeom(1, p2), pgeom(4, p2) - pgeom(1, p2)) # method 2
[1] 0.2497399 0.2297630 [1] 0.2499608 0.2144380
is the mass at 1 (dgeom) and (pgeom): careful, would leave out the 2. Method 1: 0.25 and 0.23; method 2: 0.25 and 0.21.
With R, build the table of observed frequencies (classes 0, 1, 2, 3 and 4 or more) and the expected ones under each method, and draw them together with barplot. Comment. Mark yourself with the criteria.
Solution
With R
O <- table(cut(x, c(-1, 0, 1, 2, 3, Inf), labels = c("0", "1", "2", "3", "4+")))
n <- length(x)
E1 <- n * c(dgeom(0:3, p1), 1 - pgeom(3, p1))
E2 <- n * c(dgeom(0:3, p2), 1 - pgeom(3, p2))
round(rbind(O, E1, E2), 2)
barplot(rbind(O, E1, E2), beside = TRUE, legend.text = c("Observed", "Mean", "Variance"))0 1 2 3 4+ O 15.00 6.00 4.00 3.00 2.00 E1 14.52 7.49 3.87 2.00 2.13 E2 15.19 7.50 3.70 1.83 1.78
Marking criteria:
- Observed table with the five classes (the last one, «4 or more») 0.25
- Expected = n · probability of each class, with the tail in the last one 0.25
barplotwithbeside = TRUEand a legend 0.25- Comments on the classes where each model departs from the data 0.25
The expected frequencies must add up to n, like the observed ones: that is why the last class is «4 or more» (the tail), not «4». Look at the output: the two models split the frequency differently between 0 and the high classes.
To choose a model you use , with the classes of the previous part; the smaller value is preferred. Compute it for both methods and choose.
Solution
- χ² method 1 0.83
- χ² method 2 1.10
- I choose Method 1 (mean)
With R
c(sum((O - E1)^2 / E1), sum((O - E2)^2 / E2))
[1] 0.8309271 1.1035482
is 0.83 with method 1 and 1.10 with method 2: method 1 wins. It is a distance between what was observed and what was expected, each squared difference relative to what was expected.
At the express checkout, the cashier spends an exponential time with mean 1.5 minutes on each customer, independent of the others. Let T be the time she takes to serve the 8 in the queue. Explain which distribution T follows and give its parameters.
Solution
- Shape 8
- Rate λ 0.67
With R
n <- 8; la <- 1 / 1.5 c(n, la) # T ~ gamma(shape n, rate λ)
[1] 8.0000000 0.6666667
T is the sum of 8 independent exponentials with rate (mean 1.5 minutes). Each one’s mgf is and the sum’s is the product, , which is a gamma’s: , with mean 12 minutes.
With R, find the probability that she serves the 8 in under 10 minutes.
Solution
- P(T < 10) 0.35
With R
pgamma(10, shape = n, rate = la) # P(T < 10)
[1] 0.3517529
pgamma(10, shape = 8, rate = λ) = 0.35.
With R, find the 90th percentile of T and interpret it.
Solution
- 0.90 quantile 17.66
With R
qgamma(0.9, shape = n, rate = la)
[1] 17.65637
qgamma(0.9, 8, λ) = 17.66: 90% of the time T does not exceed 17.66 minutes (and one in ten times it does).
The parts are linked: each one often needs the one before.
Let X be the number of offers the supermarket app shows in one purchase. Its mass function is , for , with . Find K so that is a mass function for every value of the parameter.
Solution
Check with R
la <- 2; x <- 0:100 # check value and many terms fx <- exp(-la) / (1 + la) * (x + 1) * la^x / factorial(x) sum(fx) # 1
[1] 1
Marking criteria:
- Checks that no term is negative 1.0
- Recognises the sum: the exponential series split in two, 2.0
- Solves 1.0
- States for which parameter values it holds (all those in the statement) 1.0
Two things: no term is negative and they add up to 1. The sum is the exponential series split in two, , so . In R you check it by adding many terms for a specific parameter value (the code adds up to 1 with ).
Find the moment generating function . Check: with , give and .
Solution
- φ(0.1) 1.32
- P(X = 1) 0.18
With R
t <- 0.1 c(sum(exp(t * x) * fx), exp(la * (exp(t) - 1)) * (1 + la * exp(t)) / (1 + la), fx[x == 1]) # φ(0.1) with sums and with the formula; P(X = 1)
[1] 1.320627 1.320627 0.180447
Put inside the sum and group it with the power of the parameter: you get the same sum as in the previous part with another argument, , for every t. With : and .
Find . Check: its value with .
Solution
- E(X) 2.67
With R
c(sum(x * fx), la + la / (1 + la)) # E(X) with sums and with the formula
[1] 2.666667 2.666667
Differentiating the mgf at 0 (or summing directly): . With , 2.67. The code checks it with a long sum.
It adds up separately: up to 2.5 more points, on top of the 50.
Let and . Using only the moment generating function of X, find .
Solution
- E(eˣ) 2.37
With R
(4 / (4 - 1))^3 # with the mgf set.seed(1) mean(exp(rgamma(1e6, 3, 4))) # simulating: almost the same
[1] 2.37037 [1] 2.370225
with , which exists because : . It is 2.37.
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Let be the time (in minutes) each of the 25 students in a class takes to scan their notes at the library, independent with common density , . Let ; you need . Using R and applying, if possible, the central limit theorem, find the requested probability approximately. Also give the mean and the variance of each .
Solution
- E(Xᵢ) 2
- Var(Xᵢ) 2
- P(S ≤ 45) 0.24
With R
f <- function(x) x * exp(-x) mu <- integrate(function(x) x * f(x), 0, Inf)$value s2 <- integrate(function(x) x^2 * f(x), 0, Inf)$value - mu^2 n <- 25 c(mu, s2, pnorm(45, n * mu, sqrt(n * s2))) # P(S <= 45) by the CLT
[1] 2.0000000 2.0000000 0.2397501
and (finite, so the CLT applies). With , and the requested probability is 0.24.
Two friends arrive at the library at independent times X and Y, uniform between 8:00 and 10:00 (in hours from 8:00, uniform on (0, 2)). Find the distribution of . Mark yourself with the criteria.
Solution
Marking criteria:
- Introduces an auxiliary variable (for example ) and writes the inverse 1.0
- Computes the Jacobian and its absolute value 1.0
- Writes the joint density of (U, V) and its support (drawn) 1.5
- Integrates out V piece by piece and reaches : 2.0
- Checks that integrates to 1 (or draws its shape) 0.5
With : , and where and . For , runs from to 2; for , from 0 to . Both give : a triangle.
Check of the above: give and .
Solution
- f_U(0.5) 0.38
- P(U > 1) 0.13
With R
fU <- function(u) integrate(function(v) dunif(u + v, 0, 2) * dunif(v, 0, 2), max(0, -u), min(2, 2 - u))$value c(fU(0.5), integrate(Vectorize(fU), 1, 2)$value) # f_U(0.5) and P(U > 1) set.seed(5) mean(runif(1e5, 0, 2) - runif(1e5, 0, 2) > 1) # simulating
[1] 0.375 0.125 [1] 0.12453
With the density of the previous part, and . The code integrates the joint density numerically at each point and the simulation gives almost the same.
The number of books returned late each hour follows a Poisson . Let be a simple random sample. Prove that the maximum likelihood estimator of is unbiased, consistent and efficient. Mark yourself with the criteria.
Solution
Marking criteria:
- Writes the log-likelihood, differentiates, sets it to 0 and reaches the MLE: 2.0
- Unbiased: computes of the estimator and gets the parameter 1.5
- Consistent: unbiased and with variance 1.5
- Computes the Fisher information and the bound 1.5
- Concludes it is efficient: its variance attains the bound 0.5
gives ; , ; and the bound is : it attains it.
Check: with and , give the variance of the MLE and the Cramér-Rao bound (with four decimals).
Solution
- Var(MLE) 0.0800
- CR bound 0.0800
- Efficient? Yes
With R
la <- 4; n <- 50 c(la / n, 1 / (n / la)) # Var of the MLE and Cramér-Rao bound set.seed(3); e <- replicate(10000, mean(rpois(n, la))) c(mean(e), var(e)) # simulating: mean and variance of the MLE
[1] 0.08 0.08 [1] 3.9985220 0.0814484
and the bound : they match, so it is efficient. Simulating 10,000 samples gives an estimator mean almost equal to the parameter (unbiased) and a variance almost equal to the bound.
The parts are linked: each one often needs the one before.
Data for part 2.a:
before <- c(12.6, 6.5, 11, 17.5, 17.3, 15.1, 10.8, 9.8, 11.1, 12.6,
10.3, 13.7, 17.6, 15.8, 16, 18.4, 16.9, 15.8, 16.4, 13.6,
13.7, 15.5, 11.3, 12.2, 11)Data for part 2.b:
after <- c(11, 7, 8.1, 16.8, 18.2, 13.5, 9.2, 8.9, 11.6, 12.7,
9.3, 13.6, 16.9, 14.4, 17.1, 17.8, 15, 14.8, 17.2, 13.6,
13.4, 13.7, 9.9, 11.1, 12.4)The time (in minutes) 25 students take to solve a sudoku was measured. The data are already in the before vector of your script.
Assuming normal data with and unknown, give a maximum likelihood estimate of each parameter and a 90% confidence interval for each one. Use R.
Solution
- μ̂ 13.70
- μ: lower 12.66
- μ: upper 14.74
- σ̂² 8.81
- σ²: lower 6.05
- σ²: upper 15.91
With R
before <- c(12.6, 6.5, 11, 17.5, 17.3, 15.1, 10.8, 9.8, 11.1, 12.6,
10.3, 13.7, 17.6, 15.8, 16, 18.4, 16.9, 15.8, 16.4, 13.6,
13.7, 15.5, 11.3, 12.2, 11)
after <- c(11, 7, 8.1, 16.8, 18.2, 13.5, 9.2, 8.9, 11.6, 12.7,
9.3, 13.6, 16.9, 14.4, 17.1, 17.8, 15, 14.8, 17.2, 13.6,
13.4, 13.7, 9.9, 11.1, 12.4)
x <- before; n <- length(x)
c(mean(x), t.test(x, conf.level = 0.9)$conf.int) # μ: estimate and interval
s2 <- var(x); a <- 0.1
c((n - 1) * s2 / n, (n - 1) * s2 / qchisq(1 - a / 2, n - 1), (n - 1) * s2 / qchisq(a / 2, n - 1)) # σ²[1] 13.70000 12.66321 14.73679 [1] 8.813600 6.050799 15.910835
; its interval, with the t: . The MLE of divides by n: ; its interval, with the chi-squared: , which is not symmetric.
After a logic workshop, the same 25 students solve another sudoku of the same difficulty. The data are in after, in the same order. With R, give a 95% interval for the variance ratio . Can they be assumed equal?
Solution
- Lower 0.39
- Upper 2.00
- Equal variances? Yes
With R
c(var.test(before, after, conf.level = 0.95)$conf.int) # σ²(before) / σ²(after)
[1] 0.3893436 2.0049712
With Snedecor’s F, the interval is . It contains 1, so there is no reason to say the variances are different.
Assume two paired normal samples and , and let with mean . Prove that follows a Student’s t with degrees of freedom. Mark yourself with the criteria.
Solution
Marking criteria:
- The are independent normals (linear combination of normals; each pair is subtracted inside) 0.75
- 0.75
- , independent of (Fisher) 0.75
- Divides the normal by : cancels and a remains 0.75
The key to paired data is that there are not two samples: there is one, the differences. From there it is the one-sample t, which is why the degrees of freedom are and not .
With the above, give a maximum likelihood estimate of the mean difference and a 95% interval. Interpret it. Use R.
Solution
- d̄ -0.61
- Lower -1.06
- Upper -0.17
- Is there a change? Yes
With R
d <- after - before c(mean(d), t.test(after, before, paired = TRUE, conf.level = 0.95)$conf.int)
[1] -0.6120000 -1.0585404 -0.1654596
They are the same units measured twice, so you work with the differences: and the paired interval is . It does not contain 0: there is a real change, downwards.
The parts are linked: each one often needs the one before.
Data for part 3.e:
loans <- c(4.1, 1.6, 0.4, 8.1, 1.6, 0.4, 1.9, 0.8, 6.9, 1.6,
5.8, 1.9, 11, 0.6, 5.2)The minutes between two loans at the library desk. They are modelled with a population with density , with unknown. Let be a simple random sample. Prove that the maximum likelihood estimator is .
Solution
Marking criteria:
- Writes the log-likelihood 0.75
- Differentiates with respect to the parameter and sets it to 0 0.75
- Solves for the estimator 0.75
- Checks it is a maximum (negative second derivative) 0.75
The logarithm turns the product into a sum; differentiating and setting to 0 gives , and the second derivative is negative.
Find the distribution of .
Solution
Marking criteria:
- Sees each term is exponential 1.0
- Uses the mgf: the sum’s is the product (independence) 1.0
- Recognises the mgf of a gamma with shape n 1.0
Result: .
Find the distribution of .
Solution
Check with R
n <- 15; set.seed(4) u <- replicate(10000, sum(rexp(n, 1.5)) * 2 * 1.5) # U with any parameter value c(mean(u), var(u), 2 * n, 4 * n) # mean and variance: those of a chi-squared with 2n df
[1] 30.12315 60.48300 30.00000 60.00000
Marking criteria:
- Change of variable (or mgf) from the previous part 1.0
- Reaches: 1.5
- States it does not depend on the parameter: it is a pivot 0.5
: its distribution does not depend on the parameter, so it works as a pivot. The simulation checks it with an arbitrary parameter value.
With that pivot, build a confidence interval of level for .
Solution
Marking criteria:
- Sets with the pivot’s quantiles 1.0
- Solves for the parameter inside the probability 1.0
- Reaches: 1.0
Interval: .
The minutes between 15 consecutive loans were recorded. They are in the loans vector of your script. With R, give the estimate of and the 90% interval.
Solution
- Estimate 0.29
- Lower 0.18
- Upper 0.42
With R
loans <- c(4.1, 1.6, 0.4, 8.1, 1.6, 0.4, 1.9, 0.8, 6.9, 1.6,
5.8, 1.9, 11, 0.6, 5.2)
x <- loans; n <- length(x); a <- 0.1
T <- sum(x)
c(n / T, qchisq(a / 2, 2 * n) / (2 * T), qchisq(1 - a / 2, 2 * n) / (2 * T)) # estimate, lower and upper limit[1] 0.2890173 0.1781567 0.4217049
With : estimate 0.289 and interval .
It adds up separately: up to 5 more points, on top of the 50.
The hits (1) and misses (0) of two class groups on the 20 questions of a speed-reading test are compared:
First: c(0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0)
Second: c(0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1)
With R, give a maximum likelihood estimate of each proportion and of their difference.
Solution
- p̂₁ 0.65
- p̂₂ 0.60
- p̂₁ − p̂₂ 0.05
With R
x <- c(0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0) y <- c(0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1) p1 <- mean(x); p2 <- mean(y) c(p1, p2, p1 - p2)
[1] 0.65 0.60 0.05
The MLE of a proportion is the sample proportion: 0.65 and 0.60; the difference, 0.05.
Give a 95% asymptotic confidence interval for . Are they different?
Solution
- Lower -0.25
- Upper 0.35
- Different? No
With R
m <- length(x); n <- length(y); z <- qnorm(0.975) (p1 - p2) + c(-1, 1) * z * sqrt(p1 * (1 - p1) / m + p2 * (1 - p2) / n)
[1] -0.2496566 0.3496566
. It contains 0: you cannot say they are different.
Let and , all independent. With R, find such that .
Solution
- a 3.22
With R
# W = [Σ(Xi - 3)² / 4 / 6] / [Σ Yj² / 9 / 10] ~ F(6, 10) qf(0.95, 6, 10)
[1] 3.217175
and ; the ratio, each over its degrees of freedom (24 = 4·6, 90 = 9·10), is an , and is its 0.95 quantile. You get .
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Data for part 1.3.a:
claims <- c(2, 0, 0, 0, 0, 0, 5, 1, 0, 1,
3, 3, 1, 1, 3, 0, 1, 0, 0, 0,
1, 0, 1, 0, 1, 1, 3, 0, 1, 1)Let A = «there is no hot water» and B = «the wifi fails» be two independent events, with and . Find from A and B and compare it with . Are and independent?
Solution
- P(Aᶜ ∩ Bᶜ) 0.53
- P(Aᶜ)·P(Bᶜ) 0.53
- Independent? Yes
With R
pa <- 0.25; pb <- 0.3 1 - (pa + pb - pa * pb) # P(Ac ∩ Bc) = 1 - P(A ∪ B) (1 - pa) * (1 - pb) # the product of their probabilities
[1] 0.525 [1] 0.525
By De Morgan, , and . They match, so they are independent: it is not a coincidence of these numbers, it is what you prove in the next part.
Prove that, if A and B are independent, so are and . Mark yourself with the criteria.
Solution
Marking criteria:
- Uses De Morgan: 0.75
- Writes 0.75
- Uses independence: 0.75
- Factorises: 0.75
The idea is always the same: split the event into disjoint pieces (or go to the complement with De Morgan), solve for the intersection you need and plug in independence. In the exam, write the property you use at each step: that is what earns the marks.
Let X be the fraction of rooms booked online in a week, a continuous variable on (0, 1) with density for (and 0 elsewhere). Find K so that f is a density.
Solution
- K 1.50
With R
g <- function(x) 1 - x^2 # the density without K K <- 1 / integrate(g, 0, 1)$value K
[1] 1.5
, so (1.5000 as a decimal). A density cannot be negative anywhere, and here it is not.
Find the mean and the variance of X.
Solution
- E(X) 0.38
- Var(X) 0.06
With R
f <- function(x) K * g(x) EX <- integrate(function(x) x * f(x), 0, 1)$value VX <- integrate(function(x) x^2 * f(x), 0, 1)$value - EX^2 c(EX, VX)
[1] 0.375000 0.059375
and , so . With two decimals: 0.38 and 0.06.
Find the distribution function of X. Check: .
Solution
- F(0.5) 0.69
With R
F <- function(x) integrate(f, 0, x)$value F(0.5)
[1] 0.6875
For , ; if and if . At the check point, .
Using R’s curve function, plot the density f. Mark yourself with the criteria.
Solution
With R
curve(f, 0, 1, lwd = 2, ylab = "f(x)") abline(v = EX, lty = 2) # the mean, to place it
Marking criteria:
- Defines f in R with K and vectorised (it accepts a vector x) 0.5
- Calls
curve(f, 0, 1)(or withfromandto) 0.5 - Describes the shape: peaks at 1.5 at and falls like a parabola to 0 at 0.5
- Places the mean (and the median of the next part) on the plot 0.5
The curve you should get: peaks at 1.5 at and falls like a parabola to 0 at . If curve gives a length error, f is not vectorised: with integrate inside it would not be, which is why f is defined with the formula and not with integrals.
With R, find the median of X (for example with uniroot, or with uniroot.all from the rootSolve library).
Solution
- Median 0.35
With R
uniroot(function(x) F(x) - 0.5, c(0.001, 0.999))$root # median: F(x) = 0.5
[1] 0.3472997
The median is the x with : 0.35. It is below the mean, because the long tail is on the right.
X is the number of claims a rural hotel’s reception gets per day. It is assumed to follow a geometric (number of failures before the first success), with and . The data for 30 days are in the claims vector of your script.
Two ways to estimate : (1) set the model mean equal to the sample mean and (2) set the model variance equal to the sample variance. With R, find by both methods and compare them.
Solution
- Method 1 0.50
- Method 2 0.54
With R
claims <- c(2, 0, 0, 0, 0, 0, 5, 1, 0, 1,
3, 3, 1, 1, 3, 0, 1, 0, 0, 0,
1, 0, 1, 0, 1, 1, 3, 0, 1, 1)
x <- claims; m <- mean(x); s2 <- var(x)
p1 <- 1 / (1 + m) # mean: (1 - p)/p = sample mean
p2 <- (-1 + sqrt(1 + 4 * s2)) / (2 * s2) # variance: (1 - p)/p^2 = sample variance
c(m, s2, p1, p2)[1] 1.0000000 1.5862069 0.5000000 0.5390641
Sample mean 1.00 and sample variance 1.59. (1) gives . (2) is the quadratic , whose positive root is . If the model were perfect, the two would be very close; the further apart they are, the more suspicious the model.
With R and for each method, find the probability of exactly one claim, , and of between 2 and 4, .
Solution
- P(X = 1), meth. 1 0.25
- P(2 ≤ X ≤ 4), meth. 1 0.22
- P(X = 1), meth. 2 0.25
- P(2 ≤ X ≤ 4), meth. 2 0.19
With R
c(dgeom(1, p1), pgeom(4, p1) - pgeom(1, p1)) # method 1: P(X = 1), P(2 <= X <= 4) c(dgeom(1, p2), pgeom(4, p2) - pgeom(1, p2)) # method 2
[1] 0.25000 0.21875 [1] 0.2484740 0.1916553
is the mass at 1 (dgeom) and (pgeom): careful, would leave out the 2. Method 1: 0.25 and 0.22; method 2: 0.25 and 0.19.
With R, build the table of observed frequencies (classes 0, 1, 2, 3 and 4 or more) and the expected ones under each method, and draw them together with barplot. Comment. Mark yourself with the criteria.
Solution
With R
O <- table(cut(x, c(-1, 0, 1, 2, 3, Inf), labels = c("0", "1", "2", "3", "4+")))
n <- length(x)
E1 <- n * c(dgeom(0:3, p1), 1 - pgeom(3, p1))
E2 <- n * c(dgeom(0:3, p2), 1 - pgeom(3, p2))
round(rbind(O, E1, E2), 2)
barplot(rbind(O, E1, E2), beside = TRUE, legend.text = c("Observed", "Mean", "Variance"))0 1 2 3 4+ O 13.00 11.00 1.00 4.00 1.00 E1 15.00 7.50 3.75 1.88 1.88 E2 16.17 7.45 3.44 1.58 1.35
Marking criteria:
- Observed table with the five classes (the last one, «4 or more») 0.5
- Expected = n · probability of each class, with the tail in the last one 0.5
barplotwithbeside = TRUEand a legend 0.5- Comments on the classes where each model departs from the data 0.5
The expected frequencies must add up to n, like the observed ones: that is why the last class is «4 or more» (the tail), not «4». Look at the output: the two models split the frequency differently between 0 and the high classes.
To choose a model you use , with the classes of the previous part; the smaller value is preferred. Compute it for both methods and choose.
Solution
- χ² method 1 6.73
- χ² method 2 7.81
- I choose Method 1 (mean)
With R
c(sum((O - E1)^2 / E1), sum((O - E2)^2 / E2))
[1] 6.733333 7.814793
is 6.73 with method 1 and 7.81 with method 2: method 1 wins. It is a distance between what was observed and what was expected, each squared difference relative to what was expected.
It has 2 independent parts (2.1, 2.2…); within each one, a part often needs the one before.
The number N of guests arriving at the hotel on a weekend follows a Poisson with mean 40. Using Chebyshev’s inequality, find a lower bound for .
Solution
- Lower bound 0.60
With R
la <- 40; k <- 10 1 - la / k^2 # Chebyshev bound
[1] 0.6
and . The interval is , so .
Using R, compare with the exact value.
Solution
- Exact 0.90
With R
ppois(50, la) - ppois(29, la) # exact
[1] 0.9041433
The exact value is 0.90, much more than the bound 0.60: Chebyshev holds for any distribution, which is why it falls short.
Let X be the number of towels lost in a week (the laundry system only gives odd numbers). Its mass function is , for (odd only), with . Find K so that is a mass function for every value of the parameter.
Solution
Check with R
la <- 1.2; x <- seq(1, 101, by = 2) # check value and many terms fx <- 1 / sinh(la) * la^x / factorial(x) sum(fx) # 1
[1] 1
Marking criteria:
- Checks that no term is negative 1.0
- Recognises the sum: the odd half of the exponential series, 2.0
- Solves 1.0
- States for which parameter values it holds (all those in the statement) 1.0
Two things: no term is negative and they add up to 1. The sum is the odd half of the exponential series, , so . In R you check it by adding many terms for a specific parameter value (the code adds up to 1 with ).
Find the moment generating function . Check: with , give and .
Solution
- φ(0.1) 1.16
- P(X = 1) 0.79
With R
t <- 0.1 c(sum(exp(t * x) * fx), sinh(la * exp(t)) / sinh(la), fx[x == 1]) # φ(0.1) with sums and with the formula; P(X = 1)
[1] 1.1597644 1.1597644 0.7949856
Put inside the sum and group it with the power of the parameter: you get the same sum as in the previous part with another argument, , for every t. With : and .
Find . Check: its value with .
Solution
- E(X) 1.44
With R
c(sum(x * fx), la / tanh(la)) # E(X) with sums and with the formula
[1] 1.439445 1.439445
Differentiating the mgf at 0 (or summing directly): . With , 1.44. The code checks it with a long sum.
It has 3 independent parts (3.1, 3.2…); within each one, a part often needs the one before.
Data for part 3.3.a:
before <- c(152, 134, 204, 158, 155, 181, 174, 160, 130, 177,
169, 167, 121, 165, 173, 148, 163, 162, 139, 167,
172, 156, 134, 147, 147)Data for part 3.3.b:
after <- c(108, 101, 199, 151, 145, 162, 166, 151, 112, 164,
171, 146, 113, 158, 141, 138, 148, 137, 108, 156,
149, 121, 126, 134, 133)Two guests come down to breakfast at independent times X and Y, uniform within the first hour of the buffet (in hours, uniform on (0, 1)). Find the distribution of . Mark yourself with the criteria.
Solution
Marking criteria:
- Introduces an auxiliary variable (for example ) and writes the inverse 1.0
- Computes the Jacobian and its absolute value 1.0
- Writes the joint density of (U, V) and its support (drawn) 1.5
- Integrates out V piece by piece and reaches : 2.0
- Checks that integrates to 1 (or draws its shape) 0.5
With : where and . The range of has length if and if : the triangle .
Check of the above: give and .
Solution
- f_U(0.25) 0.75
- P(U > 0.5) 0.13
With R
fU <- function(u) integrate(function(v) dunif(u + v) * dunif(v), max(0, -u), min(1, 1 - u))$value c(fU(0.25), integrate(Vectorize(fU), 0.5, 1)$value) # f_U(0.25) and P(U > 0.5) set.seed(5) mean(runif(1e5) - runif(1e5) > 0.5) # simulating
[1] 0.750 0.125 [1] 0.12453
With the density of the previous part, and . The code integrates the joint density numerically at each point and the simulation gives almost the same.
The number of breakfasts ordered to the room each morning follows a Poisson . Let be a simple random sample. Prove that the maximum likelihood estimator of is unbiased, consistent and efficient. Mark yourself with the criteria.
Solution
Marking criteria:
- Writes the log-likelihood, differentiates, sets it to 0 and reaches the MLE: 2.0
- Unbiased: computes of the estimator and gets the parameter 1.5
- Consistent: unbiased and with variance 1.5
- Computes the Fisher information and the bound 1.5
- Concludes it is efficient: its variance attains the bound 0.5
, unbiased, with (consistent) and equal to the bound (efficient).
Check: with and , give the variance of the MLE and the Cramér-Rao bound (with four decimals).
Solution
- Var(MLE) 0.0625
- CR bound 0.0625
- Efficient? Yes
With R
la <- 2.5; n <- 40 c(la / n, 1 / (n / la)) # Var of the MLE and Cramér-Rao bound set.seed(3); e <- replicate(10000, mean(rpois(n, la))) c(mean(e), var(e)) # simulating: mean and variance of the MLE
[1] 0.0625 0.0625 [1] 2.501008 0.062072
and the bound : they match, so it is efficient. Simulating 10,000 samples gives an estimator mean almost equal to the parameter (unbiased) and a variance almost equal to the bound.
The water use (in litres per day) of 25 rooms was measured. The data are already in the before vector of your script.
Assuming normal data with and unknown, give a maximum likelihood estimate of each parameter and a 90% confidence interval for each one. Use R.
Solution
- μ̂ 158.20
- μ: lower 151.91
- μ: upper 164.49
- σ̂² 324.64
- σ²: lower 222.88
- σ²: upper 586.06
With R
before <- c(152, 134, 204, 158, 155, 181, 174, 160, 130, 177,
169, 167, 121, 165, 173, 148, 163, 162, 139, 167,
172, 156, 134, 147, 147)
after <- c(108, 101, 199, 151, 145, 162, 166, 151, 112, 164,
171, 146, 113, 158, 141, 138, 148, 137, 108, 156,
149, 121, 126, 134, 133)
x <- before; n <- length(x)
c(mean(x), t.test(x, conf.level = 0.9)$conf.int) # μ: estimate and interval
s2 <- var(x); a <- 0.1
c((n - 1) * s2 / n, (n - 1) * s2 / qchisq(1 - a / 2, n - 1), (n - 1) * s2 / qchisq(a / 2, n - 1)) # σ²[1] 158.2000 151.9076 164.4924 [1] 324.6400 222.8750 586.0594
; its interval, with the t: . The MLE of divides by n: ; its interval, with the chi-squared: , which is not symmetric.
After fitting flow reducers, the use of the same 25 rooms is measured again. The data are in after, in the same order. With R, give a 95% interval for the variance ratio . Can they be assumed equal?
Solution
- Lower 0.28
- Upper 1.43
- Equal variances? Yes
With R
c(var.test(before, after, conf.level = 0.95)$conf.int) # σ²(before) / σ²(after)
[1] 0.2775417 1.4292342
With Snedecor’s F, the interval is . It contains 1, so there is no reason to say the variances are different.
Assume two paired normal samples and , and let with mean . Prove that follows a Student’s t with degrees of freedom. Mark yourself with the criteria.
Solution
Marking criteria:
- The are independent normals (linear combination of normals; each pair is subtracted inside) 0.75
- 0.75
- , independent of (Fisher) 0.75
- Divides the normal by : cancels and a remains 0.75
The key to paired data is that there are not two samples: there is one, the differences. From there it is the one-sample t, which is why the degrees of freedom are and not .
With the above, give a maximum likelihood estimate of the mean difference and a 95% interval. Interpret it. Use R.
Solution
- d̄ -16.68
- Lower -21.33
- Upper -12.03
- Is there a change? Yes
With R
d <- after - before c(mean(d), t.test(after, before, paired = TRUE, conf.level = 0.95)$conf.int)
[1] -16.68000 -21.32525 -12.03475
They are the same units measured twice, so you work with the differences: and the paired interval is . It does not contain 0: there is a real change, downwards.
The parts are linked: each one often needs the one before.
Data for part 4.e:
arrivals <- c(2.2, 0.2, 1.8, 2.3, 3.6, 9.5, 1.7, 1.4, 2.1, 6.2,
1.4, 2.1)The minutes between two calls to reception at night. They are modelled with a population with density , with unknown. Let be a simple random sample. Prove that the maximum likelihood estimator is .
Solution
Marking criteria:
- Writes the log-likelihood 1.25
- Differentiates with respect to the parameter and sets it to 0 1.25
- Solves for the estimator 1.25
- Checks it is a maximum (negative second derivative) 1.25
The logarithm turns the product into a sum; differentiating and setting to 0 gives , and the second derivative is negative.
Find the distribution of .
Solution
Marking criteria:
- Sees each term is exponential 1.6667
- Uses the mgf: the sum’s is the product (independence) 1.6667
- Recognises the mgf of a gamma with shape n 1.6666
Result: .
Find the distribution of .
Solution
Check with R
n <- 12; set.seed(4) u <- replicate(10000, sum(rexp(n, 1.5)) * 2 * 1.5) # U with any parameter value c(mean(u), var(u), 2 * n, 4 * n) # mean and variance: those of a chi-squared with 2n df
[1] 24.13396 48.91522 24.00000 48.00000
Marking criteria:
- Change of variable (or mgf) from the previous part 1.6667
- Reaches: 2.5
- States it does not depend on the parameter: it is a pivot 0.8333
: its distribution does not depend on the parameter, so it works as a pivot. The simulation checks it with an arbitrary parameter value.
With that pivot, build a confidence interval of level for .
Solution
Marking criteria:
- Sets with the pivot’s quantiles 1.6667
- Solves for the parameter inside the probability 1.6667
- Reaches: 1.6666
Interval: .
The minutes between 12 consecutive calls were recorded. They are in the arrivals vector of your script. With R, give the estimate of and the 90% interval.
Solution
- Estimate 0.35
- Lower 0.20
- Upper 0.53
With R
arrivals <- c(2.2, 0.2, 1.8, 2.3, 3.6, 9.5, 1.7, 1.4, 2.1, 6.2,
1.4, 2.1)
x <- arrivals; n <- length(x); a <- 0.1
T <- sum(x)
c(n / T, qchisq(a / 2, 2 * n) / (2 * T), qchisq(1 - a / 2, 2 * n) / (2 * T)) # estimate, lower and upper limit[1] 0.3478261 0.2007018 0.5277540
With : estimate 0.348 and interval .
It adds up separately: up to 10 more points, on top of the 100.
Let and . Using only the moment generating function of X, find .
Solution
- E(e²ˣ) 2.25
With R
(6 / (6 - 2))^2 # with the mgf set.seed(1) mean(exp(2 * rgamma(1e6, 2, 6))) # simulating: almost the same
[1] 2.25 [1] 2.248841
(it exists because ). It is 2.25.
Let and , all independent. With R, find such that .
Solution
- a 18.31
With R
# W = Σ(Xi - 3)² + Σ(Yj / 2)² ~ chi2(4 + 6) qchisq(0.95, 10)
[1] 18.30704
They are 10 independent squared standard normals: , and is its 0.95 quantile. You get .
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Let A = «the filament jams» and B = «the lab loses power» be two independent events, with and . Find from A and B and compare it with . Are and independent?
Solution
- P(A ∩ Bᶜ) 0.19
- P(A)·P(Bᶜ) 0.19
- Independent? Yes
With R
pa <- 0.2; pb <- 0.05 pa - pa * pb # P(A ∩ Bc) = P(A) - P(A ∩ B) pa * (1 - pb) # the product of their probabilities
[1] 0.19 [1] 0.19
Since and split A, , and . They match, so they are independent: it is not a coincidence of these numbers, it is what you prove in the next part.
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.75
- Solves 0.75
- Uses the independence of A and B 0.75
- Reaches 0.75
The idea is always the same: split the event into disjoint pieces (or go to the complement with De Morgan), solve for the intersection you need and plug in independence. In the exam, write the property you use at each step: that is what earns the marks.
Let X be the fraction of a filament spool a large part uses, a continuous variable on (0, 1) with density for (and 0 elsewhere). Find K so that f is a density.
Solution
- K 3.75
With R
g <- function(x) sqrt(x) * (1 - x) # the density without K K <- 1 / integrate(g, 0, 1)$value K
[1] 3.749999
, so (3.7500 as a decimal). A density cannot be negative anywhere, and here it is not.
Find the mean and the variance of X.
Solution
- E(X) 0.43
- Var(X) 0.05
With R
f <- function(x) K * g(x) EX <- integrate(function(x) x * f(x), 0, 1)$value VX <- integrate(function(x) x^2 * f(x), 0, 1)$value - EX^2 c(EX, VX)
[1] 0.42857130 0.05442181
and , so . With two decimals: 0.43 and 0.05.
Find the distribution function of X. Check: .
Solution
- F(0.25) 0.27
With R
F <- function(x) integrate(f, 0, x)$value F(0.25)
[1] 0.265625
For , ; if and if . At the check point, .
Using R’s curve function, plot the density f. Mark yourself with the criteria.
Solution
With R
curve(f, 0, 1, lwd = 2, ylab = "f(x)") abline(v = EX, lty = 2) # the mean, to place it
Marking criteria:
- Defines f in R with K and vectorised (it accepts a vector x) 0.5
- Calls
curve(f, 0, 1)(or withfromandto) 0.5 - Describes the shape: leaves 0 with a vertical slope, peaks at and goes down to 0 at 0.5
- Places the mean (and the median of the next part) on the plot 0.5
The curve you should get: leaves 0 with a vertical slope, peaks at and goes down to 0 at . If curve gives a length error, f is not vectorised: with integrate inside it would not be, which is why f is defined with the formula and not with integrals.
With R, find the median of X (for example with uniroot, or with uniroot.all from the rootSolve library).
Solution
- Median 0.41
With R
uniroot(function(x) F(x) - 0.5, c(0.001, 0.999))$root # median: F(x) = 0.5
[1] 0.4136281
The median is the x with : 0.41. It is below the mean, because the long tail is on the right.
The school FabLab has three 3D printers. The time T (in hours) a part takes depends on the printer: «Printer P» handles 50% and its time is gamma with shape 2 and rate 1; «Printer Q» handles 30% and its time is uniform between 1 and 4; «Printer R» handles 20% and its time is exponential with mean 3. Find the probability that a part is ready in 2 hours or less, .
Solution
- P(T ≤ 2) 0.49
With R
t <- 2
P <- c(0.5 * pgamma(t, 2, 1),
0.3 * punif(t, 1, 4),
0.2 * pexp(t, 1/3))
sum(P) # P(T <= 2)[1] 0.4943137
By total probability: , each conditional probability coming from its model. It gives 0.49.
Given that a part is ready in 2 hours or less, use R to find the probability that each one handled it.
Solution
- Printer P 0.60
- Printer Q 0.20
- Printer R 0.20
With R
P / sum(P) # P(source | T <= 2)
[1] 0.6008272 0.2023007 0.1968721
Bayes: ; each term of the previous part over the total. You get 0.60, 0.20, 0.20, which add up to 1.
It has 2 independent parts (2.1, 2.2…); within each one, a part often needs the one before.
Data for part 2.1.a:
failed <- c(0, 0, 0, 0, 1, 1, 3, 0, 1, 2,
1, 0, 1, 0, 0, 2, 0, 3, 0, 3,
2, 1, 0, 0, 2, 2, 0, 1, 2, 1,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1)X is the number of parts that come out wrong each day before the first good one on the oldest printer. It is assumed to follow a geometric (number of failures before the first success), with and . The data for 40 days are in the failed vector of your script.
Two ways to estimate : (1) set the model mean equal to the sample mean and (2) set the model variance equal to the sample variance. With R, find by both methods and compare them.
Solution
- Method 1 0.56
- Method 2 0.63
With R
failed <- c(0, 0, 0, 0, 1, 1, 3, 0, 1, 2,
1, 0, 1, 0, 0, 2, 0, 3, 0, 3,
2, 1, 0, 0, 2, 2, 0, 1, 2, 1,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1)
x <- failed; m <- mean(x); s2 <- var(x)
p1 <- 1 / (1 + m) # mean: (1 - p)/p = sample mean
p2 <- (-1 + sqrt(1 + 4 * s2)) / (2 * s2) # variance: (1 - p)/p^2 = sample variance
c(m, s2, p1, p2)[1] 0.7750000 0.9480769 0.5633803 0.6271295
Sample mean 0.78 and sample variance 0.95. (1) gives . (2) is the quadratic , whose positive root is . If the model were perfect, the two would be very close; the further apart they are, the more suspicious the model.
With R and for each method, find the probability of exactly one failed part, , and of between 2 and 4, .
Solution
- P(X = 1), meth. 1 0.25
- P(2 ≤ X ≤ 4), meth. 1 0.17
- P(X = 1), meth. 2 0.23
- P(2 ≤ X ≤ 4), meth. 2 0.13
With R
c(dgeom(1, p1), pgeom(4, p1) - pgeom(1, p1)) # method 1: P(X = 1), P(2 <= X <= 4) c(dgeom(1, p2), pgeom(4, p2) - pgeom(1, p2)) # method 2
[1] 0.2459829 0.1747690 [1] 0.2338381 0.1318248
is the mass at 1 (dgeom) and (pgeom): careful, would leave out the 2. Method 1: 0.25 and 0.17; method 2: 0.23 and 0.13.
With R, build the table of observed frequencies (classes 0, 1, 2, 3 and 4 or more) and the expected ones under each method, and draw them together with barplot. Comment. Mark yourself with the criteria.
Solution
With R
O <- table(cut(x, c(-1, 0, 1, 2, 3, Inf), labels = c("0", "1", "2", "3", "4+")))
n <- length(x)
E1 <- n * c(dgeom(0:3, p1), 1 - pgeom(3, p1))
E2 <- n * c(dgeom(0:3, p2), 1 - pgeom(3, p2))
round(rbind(O, E1, E2), 2)
barplot(rbind(O, E1, E2), beside = TRUE, legend.text = c("Observed", "Mean", "Variance"))0 1 2 3 4+ O 21.00 10.00 6.00 3.00 0.00 E1 22.54 9.84 4.30 1.88 1.45 E2 25.09 9.35 3.49 1.30 0.77
Marking criteria:
- Observed table with the five classes (the last one, «4 or more») 0.25
- Expected = n · probability of each class, with the tail in the last one 0.25
barplotwithbeside = TRUEand a legend 0.25- Comments on the classes where each model departs from the data 0.25
The expected frequencies must add up to n, like the observed ones: that is why the last class is «4 or more» (the tail), not «4». Look at the output: the two models split the frequency differently between 0 and the high classes.
To choose a model you use , with the classes of the previous part; the smaller value is preferred. Compute it for both methods and choose.
Solution
- χ² method 1 2.91
- χ² method 2 5.51
- I choose Method 1 (mean)
With R
c(sum((O - E1)^2 / E1), sum((O - E2)^2 / E2))
[1] 2.910609 5.514106
is 2.91 with method 1 and 5.51 with method 2: method 1 wins. It is a distance between what was observed and what was expected, each squared difference relative to what was expected.
A laser cutter takes an exponential time with mean 4 minutes on each small part, independent of the others. Let T be the time it takes to cut an order of 12 parts. Explain which distribution T follows and give its parameters.
Solution
- Shape 12
- Rate λ 0.25
With R
n <- 12; la <- 0.25 c(n, la) # T ~ gamma(shape n, rate λ)
[1] 12.00 0.25
T is the sum of 12 independent exponentials with rate (mean 4 minutes). Each one’s mgf is and the sum’s is the product, , which is a gamma’s: , with mean 48 minutes.
With R, find the probability that it cuts the order in under 40 minutes.
Solution
- P(T < 40) 0.30
With R
pgamma(40, shape = n, rate = la) # P(T < 40)
[1] 0.3032239
pgamma(40, shape = 12, rate = λ) = 0.30.
With R, find the 90th percentile of T and interpret it.
Solution
- 0.90 quantile 66.39
With R
qgamma(0.9, shape = n, rate = la)
[1] 66.39249
qgamma(0.9, 12, λ) = 66.39: 90% of the time T does not exceed 66.39 minutes (and one in ten times it does).
The parts are linked: each one often needs the one before.
The screws in a kit come in pairs. Let X be the number of screws left over when assembling a part. Its mass function is , for (even only), with . Find K so that is a mass function for every value of the parameter.
Solution
Check with R
la <- 1.5; x <- seq(0, 100, by = 2) # check value and many terms fx <- 1 / cosh(la) * la^x / factorial(x) sum(fx) # 1
[1] 1
Marking criteria:
- Checks that no term is negative 1.0
- Recognises the sum: the even half of the exponential series, 2.0
- Solves 1.0
- States for which parameter values it holds (all those in the statement) 1.0
Two things: no term is negative and they add up to 1. The sum is the even half of the exponential series, , so . In R you check it by adding many terms for a specific parameter value (the code adds up to 1 with ).
Find the moment generating function . Check: with , give and .
Solution
- φ(0.2) 1.36
- P(X = 2) 0.48
With R
t <- 0.2 c(sum(exp(t * x) * fx), cosh(la * exp(t)) / cosh(la), fx[x == 2]) # φ(0.2) with sums and with the formula; P(X = 2)
[1] 1.361815 1.361815 0.478233
Put inside the sum and group it with the power of the parameter: you get the same sum as in the previous part with another argument, , for every t. With : and .
Find . Check: its value with .
Solution
- E(X) 1.36
With R
c(sum(x * fx), la * tanh(la)) # E(X) with sums and with the formula
[1] 1.357722 1.357722
Differentiating the mgf at 0 (or summing directly): . With , 1.36. The code checks it with a long sum.
It adds up separately: up to 2.5 more points, on top of the 50.
Let and . Using only the moment generating function of X, find .
Solution
- E(e²ˣ) 2.78
With R
(5 / (5 - 2))^2 # with the mgf set.seed(1) mean(exp(2 * rgamma(1e6, 2, 5))) # simulating: almost the same
[1] 2.777778 [1] 2.776607
with , which exists because : . It is 2.78.
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Let be the fraction of an hour each of the 40 solar panels on the school roof gets full sun, independent with common density , . Let ; you need . Using R and applying, if possible, the central limit theorem, find the requested probability approximately. Also give the mean and the variance of each .
Solution
- E(Xᵢ) 0.60
- Var(Xᵢ) 0.07
- P(S ≥ 26) 0.11
With R
f <- function(x) 1.5 * sqrt(x) mu <- integrate(function(x) x * f(x), 0, 1)$value s2 <- integrate(function(x) x^2 * f(x), 0, 1)$value - mu^2 n <- 40 c(mu, s2, 1 - pnorm(26, n * mu, sqrt(n * s2))) # P(S >= 26) by the CLT
[1] 0.60000000 0.06857143 0.11359773
and (finite, so the CLT applies). With , and the requested probability is 0.11.
The panels’ inverter starts at a time and the battery at a time , independent (in minutes). Find the distribution of . Mark yourself with the criteria.
Solution
Marking criteria:
- Introduces an auxiliary variable (for example ) and writes the inverse 1.0
- Computes the Jacobian and its absolute value 1.0
- Writes the joint density of (U, V) and its support (drawn) 1.5
- Integrates out V piece by piece and reaches : 2.0
- Checks that integrates to 1 (or draws its shape) 0.5
With : where and . The range of has length , 1 or depending on whether is in , or : a trapezoid.
Check of the above: give and .
Solution
- f_U(-0.5) 0.50
- P(U > 0) 0.25
With R
fU <- function(u) integrate(function(v) dunif(u + v, 0, 1) * dunif(v, 0, 2), max(0, -u), min(2, 1 - u))$value c(fU(-0.5), integrate(Vectorize(fU), 0, 1)$value) # f_U(-0.5) and P(U > 0) set.seed(5) mean(runif(1e5, 0, 1) - runif(1e5, 0, 2) > 0) # simulating
[1] 0.50 0.25 [1] 0.25076
With the density of the previous part, and . The code integrates the joint density numerically at each point and the simulation gives almost the same.
Each morning you check whether a panel needs cleaning (1) or not (0): . Let be a simple random sample. Prove that the maximum likelihood estimator of is unbiased, consistent and efficient. Mark yourself with the criteria.
Solution
Marking criteria:
- Writes the log-likelihood, differentiates, sets it to 0 and reaches the MLE: 2.0
- Unbiased: computes of the estimator and gets the parameter 1.5
- Consistent: unbiased and with variance 1.5
- Computes the Fisher information and the bound 1.5
- Concludes it is efficient: its variance attains the bound 0.5
gives ; , ; and the bound equals the variance.
Check: with and , give the variance of the MLE and the Cramér-Rao bound (with four decimals).
Solution
- Var(MLE) 0.0035
- CR bound 0.0035
- Efficient? Yes
With R
p <- 0.3; n <- 60 c(p * (1 - p) / n, 1 / (n / (p * (1 - p)))) # Var of the MLE and Cramér-Rao bound set.seed(3); e <- replicate(10000, mean(rbinom(n, 1, p))) c(mean(e), var(e)) # simulating: mean and variance of the MLE
[1] 0.0035 0.0035 [1] 0.300173333 0.003484318
and the bound : they match, so it is efficient. Simulating 10,000 samples gives an estimator mean almost equal to the parameter (unbiased) and a variance almost equal to the bound.
The parts are linked: each one often needs the one before.
Data for part 2.a:
dirty <- c(4.87, 5.68, 4.4, 5.43, 4.54, 5.35, 5.98, 5.23, 5.44, 4.5,
5.23, 4.33, 6.15, 5.38, 5.4, 5.6, 5.72, 5.34, 4.52, 4.56,
5.46, 4.54, 5.2, 5.57, 6.2)Data for part 2.b:
clean <- c(5.51, 6.23, 5.26, 5.67, 5.02, 5.75, 6.06, 5.59, 5.84, 5.2,
5.52, 5.04, 6.4, 5.63, 6.15, 5.91, 6.14, 5.36, 5.32, 4.82,
6.2, 4.68, 5.19, 5.3, 6.6)The daily output (in kWh) of 25 uncleaned panels was measured. The data are already in the dirty vector of your script.
Assuming normal data with and unknown, give a maximum likelihood estimate of each parameter and a 95% confidence interval for each one. Use R.
Solution
- μ̂ 5.22
- μ: lower 5.00
- μ: upper 5.45
- σ̂² 0.29
- σ²: lower 0.19
- σ²: upper 0.59
With R
dirty <- c(4.87, 5.68, 4.4, 5.43, 4.54, 5.35, 5.98, 5.23, 5.44, 4.5,
5.23, 4.33, 6.15, 5.38, 5.4, 5.6, 5.72, 5.34, 4.52, 4.56,
5.46, 4.54, 5.2, 5.57, 6.2)
clean <- c(5.51, 6.23, 5.26, 5.67, 5.02, 5.75, 6.06, 5.59, 5.84, 5.2,
5.52, 5.04, 6.4, 5.63, 6.15, 5.91, 6.14, 5.36, 5.32, 4.82,
6.2, 4.68, 5.19, 5.3, 6.6)
x <- dirty; n <- length(x)
c(mean(x), t.test(x, conf.level = 0.95)$conf.int) # μ: estimate and interval
s2 <- var(x); a <- 0.05
c((n - 1) * s2 / n, (n - 1) * s2 / qchisq(1 - a / 2, n - 1), (n - 1) * s2 / qchisq(a / 2, n - 1)) # σ²[1] 5.224800 4.996732 5.452868 [1] 0.2930650 0.1861246 0.5908020
; its interval, with the t: . The MLE of divides by n: ; its interval, with the chi-squared: , which is not symmetric.
After cleaning them, the output of the same 25 panels is measured again on a similarly sunny day. The data are in clean, in the same order. With R, give a 90% interval for the variance ratio . Can they be assumed equal?
Solution
- Lower 0.60
- Upper 2.36
- Equal variances? Yes
With R
c(var.test(dirty, clean, conf.level = 0.9)$conf.int) # σ²(dirty) / σ²(clean)
[1] 0.5988217 2.3565443
With Snedecor’s F, the interval is . It contains 1, so there is no reason to say the variances are different.
Assume two paired normal samples and , and let with mean . Prove that follows a Student’s t with degrees of freedom. Mark yourself with the criteria.
Solution
Marking criteria:
- The are independent normals (linear combination of normals; each pair is subtracted inside) 0.75
- 0.75
- , independent of (Fisher) 0.75
- Divides the normal by : cancels and a remains 0.75
The key to paired data is that there are not two samples: there is one, the differences. From there it is the one-sample t, which is why the degrees of freedom are and not .
With the above, give a maximum likelihood estimate of the mean difference and a 99% interval. Interpret it. Use R.
Solution
- d̄ 0.39
- Lower 0.23
- Upper 0.55
- Is there a change? Yes
With R
d <- clean - dirty c(mean(d), t.test(clean, dirty, paired = TRUE, conf.level = 0.99)$conf.int)
[1] 0.3908000 0.2324171 0.5491829
They are the same units measured twice, so you work with the differences: and the paired interval is . It does not contain 0: there is a real change, upwards.
The parts are linked: each one often needs the one before.
Data for part 3.e:
logs <- c(1.38, 1.64, 15.22, 2.41, 1.11, 1.73, 1.34, 1.2, 1.37, 2.45,
1.07, 1.05)The sizes (in MB) of the inverter’s log files above 1 MB. They are modelled with a population with density , with unknown (and known). Let be a simple random sample. Prove that the maximum likelihood estimator is .
Solution
Marking criteria:
- Writes the log-likelihood 0.75
- Differentiates with respect to the parameter and sets it to 0 0.75
- Solves for the estimator 0.75
- Checks it is a maximum (negative second derivative) 0.75
The logarithm turns the product into a sum; differentiating and setting to 0 gives , and the second derivative is negative.
Find the distribution of .
Solution
Marking criteria:
- Sees each term is exponential (change of variable) 1.0
- Uses the mgf: the sum’s is the product (independence) 1.0
- Recognises the mgf of a gamma with shape n 1.0
Result: .
Find the distribution of .
Solution
Check with R
n <- 12; set.seed(4) u <- replicate(10000, 2 * 1.5 * sum(rexp(n, 1.5))) # U with any parameter value c(mean(u), var(u), 2 * n, 4 * n) # mean and variance: those of a chi-squared with 2n df
[1] 24.13396 48.91522 24.00000 48.00000
Marking criteria:
- Change of variable (or mgf) from the previous part 1.0
- Reaches: 1.5
- States it does not depend on the parameter: it is a pivot 0.5
: its distribution does not depend on the parameter, so it works as a pivot. The simulation checks it with an arbitrary parameter value.
With that pivot, build a confidence interval of level for .
Solution
Marking criteria:
- Sets with the pivot’s quantiles 1.0
- Solves for the parameter inside the probability 1.0
- Reaches: 1.0
Interval: .
12 files were measured. They are in the logs vector of your script. With R, give the estimate of and the 95% interval.
Solution
- Estimate 1.75
- Lower 0.90
- Upper 2.86
With R
logs <- c(1.38, 1.64, 15.22, 2.41, 1.11, 1.73, 1.34, 1.2, 1.37, 2.45,
1.07, 1.05)
x <- logs; n <- length(x); a <- 0.05
T <- sum(log(x))
c(n / T, qchisq(a / 2, 2 * n) / (2 * T), qchisq(1 - a / 2, 2 * n) / (2 * T)) # estimate, lower and upper limit[1] 1.7457499 0.9020544 2.8633263
With : estimate 1.75 and interval .
It adds up separately: up to 5 more points, on top of the 50.
For two different roofs, it is recorded whether the panel exceeds 90% of its rating (1) or not (0) on 24 days:
First: c(1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1)
Second: c(1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1)
With R, give a maximum likelihood estimate of each proportion and of their difference.
Solution
- p̂₁ 0.88
- p̂₂ 0.50
- p̂₁ − p̂₂ 0.38
With R
x <- c(1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1) y <- c(1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1) p1 <- mean(x); p2 <- mean(y) c(p1, p2, p1 - p2)
[1] 0.875 0.500 0.375
The MLE of a proportion is the sample proportion: 0.88 and 0.50; the difference, 0.38.
Give a 95% asymptotic confidence interval for . Are they different?
Solution
- Lower 0.14
- Upper 0.61
- Different? Yes
With R
m <- length(x); n <- length(y); z <- qnorm(0.975) (p1 - p2) + c(-1, 1) * z * sqrt(p1 * (1 - p1) / m + p2 * (1 - p2) / n)
[1] 0.1351629 0.6148371
. It does not contain 0: they are different.
Let be independent. With R, find such that .
Solution
- a 3.49
With R
# W = Σ((Xi - 5) / 2)² ~ chi2(8); P(W >= a) = 0.90 => a is the 0.10 quantile qchisq(0.10, 8)
[1] 3.489539
Each term is a squared standard normal, so the sum is a . The right tail being 0.90 means is its 0.10 quantile. You get .
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Data for part 1.3.a:
returns <- c(3, 3, 2, 2, 1, 2, 2, 2, 1, 3,
0, 4, 3, 2, 1, 1, 1, 1, 3, 4,
3, 2, 3, 2, 2, 4, 5, 4, 2, 3,
5, 3, 2, 4, 3)Let A = «a T-shirt comes out with a print defect» and B = «the order is urgent» be two independent events, with and . Find from A and B and compare it with . Are and independent?
Solution
- P(A ∩ Bᶜ) 0.09
- P(A)·P(Bᶜ) 0.09
- Independent? Yes
With R
pa <- 0.12; pb <- 0.25 pa - pa * pb # P(A ∩ Bc) = P(A) - P(A ∩ B) pa * (1 - pb) # the product of their probabilities
[1] 0.09 [1] 0.09
Since and split A, , and . They match, so they are independent: it is not a coincidence of these numbers, it is what you prove in the next part.
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.75
- Solves 0.75
- Uses the independence of A and B 0.75
- Reaches 0.75
The idea is always the same: split the event into disjoint pieces (or go to the complement with De Morgan), solve for the intersection you need and plug in independence. In the exam, write the property you use at each step: that is what earns the marks.
Let X be the fraction of a vinyl roll used on a large order, a continuous variable on (0, 1) with density for (and 0 elsewhere). Find K so that f is a density.
Solution
- K 1.50
With R
g <- function(x) x * (2 - x) # the density without K K <- 1 / integrate(g, 0, 1)$value K
[1] 1.5
, so (1.5000 as a decimal). A density cannot be negative anywhere, and here it is not.
Find the mean and the variance of X.
Solution
- E(X) 0.63
- Var(X) 0.06
With R
f <- function(x) K * g(x) EX <- integrate(function(x) x * f(x), 0, 1)$value VX <- integrate(function(x) x^2 * f(x), 0, 1)$value - EX^2 c(EX, VX)
[1] 0.625000 0.059375
and , so . With two decimals: 0.63 and 0.06.
Find the distribution function of X. Check: .
Solution
- F(0.4) 0.21
With R
F <- function(x) integrate(f, 0, x)$value F(0.4)
[1] 0.208
For , ; if and if . At the check point, .
Using R’s curve function, plot the density f. Mark yourself with the criteria.
Solution
With R
curve(f, 0, 1, lwd = 2, ylab = "f(x)") abline(v = EX, lty = 2) # the mean, to place it
Marking criteria:
- Defines f in R with K and vectorised (it accepts a vector x) 0.5
- Calls
curve(f, 0, 1)(or withfromandto) 0.5 - Describes the shape: starts at 0 and grows, ever more slowly, up to 1.5 at 0.5
- Places the mean (and the median of the next part) on the plot 0.5
The curve you should get: starts at 0 and grows, ever more slowly, up to 1.5 at . If curve gives a length error, f is not vectorised: with integrate inside it would not be, which is why f is defined with the formula and not with integrals.
With R, find the median of X (for example with uniroot, or with uniroot.all from the rootSolve library).
Solution
- Median 0.65
With R
uniroot(function(x) F(x) - 0.5, c(0.001, 0.999))$root # median: F(x) = 0.5
[1] 0.6527003
The median is the x with : 0.65. It is above the mean, because the long tail is on the left.
X is the number of orders returned each day at an online T-shirt shop. It is assumed to follow a Poisson , with . The data for 35 days are in the returns vector of your script.
Two ways to estimate : (1) set the model mean equal to the sample mean and (2) set the model variance equal to the sample variance. With R, find by both methods and compare them.
Solution
- Method 1 2.51
- Method 2 1.43
With R
returns <- c(3, 3, 2, 2, 1, 2, 2, 2, 1, 3,
0, 4, 3, 2, 1, 1, 1, 1, 3, 4,
3, 2, 3, 2, 2, 4, 5, 4, 2, 3,
5, 3, 2, 4, 3)
x <- returns; m <- mean(x); s2 <- var(x)
l1 <- m # mean: λ = sample mean
l2 <- s2 # variance: λ = sample variance
c(m, s2, l1, l2)[1] 2.514286 1.433613 2.514286 1.433613
In the Poisson the mean and the variance are both λ, so (1) gives and (2) . If the data were Poisson, the sample mean and variance would be close; here the variance is smaller than the mean.
With R and for each method, find the probability of exactly one return, , and of between 2 and 4, .
Solution
- P(X = 1), meth. 1 0.20
- P(2 ≤ X ≤ 4), meth. 1 0.60
- P(X = 1), meth. 2 0.34
- P(2 ≤ X ≤ 4), meth. 2 0.40
With R
c(dpois(1, l1), ppois(4, l1) - ppois(1, l1)) # method 1: P(X = 1), P(2 <= X <= 4) c(dpois(1, l2), ppois(4, l2) - ppois(1, l2)) # method 2
[1] 0.2034577 0.6048828 [1] 0.3418390 0.4040934
is the mass at 1 (dpois) and (ppois): careful, would leave out the 2. Method 1: 0.20 and 0.60; method 2: 0.34 and 0.40.
With R, build the table of observed frequencies (classes 0, 1, 2, 3 and 4 or more) and the expected ones under each method, and draw them together with barplot. Comment. Mark yourself with the criteria.
Solution
With R
O <- table(cut(x, c(-1, 0, 1, 2, 3, Inf), labels = c("0", "1", "2", "3", "4+")))
n <- length(x)
E1 <- n * c(dpois(0:3, l1), 1 - ppois(3, l1))
E2 <- n * c(dpois(0:3, l2), 1 - ppois(3, l2))
round(rbind(O, E1, E2), 2)
barplot(rbind(O, E1, E2), beside = TRUE, legend.text = c("Observed", "Mean", "Variance"))0 1 2 3 4+ O 1.00 6.00 11.00 10.0 7.00 E1 2.83 7.12 8.95 7.5 8.59 E2 8.35 11.96 8.58 4.1 2.02
Marking criteria:
- Observed table with the five classes (the last one, «4 or more») 0.5
- Expected = n · probability of each class, with the tail in the last one 0.5
barplotwithbeside = TRUEand a legend 0.5- Comments on the classes where each model departs from the data 0.5
The expected frequencies must add up to n, like the observed ones: that is why the last class is «4 or more» (the tail), not «4». Look at the output: the two models split the frequency differently between 0 and the high classes.
To choose a model you use , with the classes of the previous part; the smaller value is preferred. Compute it for both methods and choose.
Solution
- χ² method 1 2.96
- χ² method 2 30.95
- I choose Method 1 (mean)
With R
c(sum((O - E1)^2 / E1), sum((O - E2)^2 / E2))
[1] 2.956375 30.948417
is 2.96 with method 1 and 30.95 with method 2: method 1 wins. It is a distance between what was observed and what was expected, each squared difference relative to what was expected.
It has 2 independent parts (2.1, 2.2…); within each one, a part often needs the one before.
The number N of orders coming in on a Monday follows a Poisson with mean 90. Using Chebyshev’s inequality, find a lower bound for .
Solution
- Lower bound 0.60
With R
la <- 90; k <- 15 1 - la / k^2 # Chebyshev bound
[1] 0.6
and . The interval is , so .
Using R, compare with the exact value.
Solution
- Exact 0.90
With R
ppois(105, la) - ppois(74, la) # exact
[1] 0.8981636
The exact value is 0.90, much more than the bound 0.60: Chebyshev holds for any distribution, which is why it falls short.
Let X be the number of T-shirts in a bulk order (at least two). Its mass function is , for , with . Find K so that is a mass function for every value of the parameter.
Solution
Check with R
la <- 1.5; x <- 2:100 # check value and many terms fx <- la^x / factorial(x) / (exp(la) - 1 - la) sum(fx) # 1
[1] 1
Marking criteria:
- Checks that no term is negative 1.0
- Recognises the sum: the exponential series without its first two terms, 2.0
- Solves 1.0
- States for which parameter values it holds (all those in the statement) 1.0
Two things: no term is negative and they add up to 1. The sum is the exponential series without its first two terms, , so . In R you check it by adding many terms for a specific parameter value (the code adds up to 1 with ).
Find the moment generating function . Check: with , give and .
Solution
- φ(0.2) 1.72
- P(X = 2) 0.57
With R
t <- 0.2 c(sum(exp(t * x) * fx), (exp(la * exp(t)) - 1 - la * exp(t)) / (exp(la) - 1 - la), fx[x == 2]) # φ(0.2) with sums and with the formula; P(X = 2)
[1] 1.7232336 1.7232336 0.5676975
Put inside the sum and group it with the power of the parameter: you get the same sum as in the previous part with another argument, , for every t. With : and .
Find . Check: its value with .
Solution
- E(X) 2.64
With R
c(sum(x * fx), la * (exp(la) - 1) / (exp(la) - 1 - la)) # E(X) with sums and with the formula
[1] 2.635395 2.635395
Differentiating the mgf at 0 (or summing directly): . With , 2.64. The code checks it with a long sum.
It has 3 independent parts (3.1, 3.2…); within each one, a part often needs the one before.
Data for part 3.3.a:
before <- c(2.85, 3.57, 3.82, 2.97, 3.95, 3.19, 3.64, 3.68, 2.91, 3.34,
3.28, 3.95, 3.97, 3.83, 3.52, 3.28, 3.26, 3.72, 2.71, 3.97,
4.11, 3.87, 2.32, 3.05, 3.28)Data for part 3.3.b:
after <- c(2.72, 2.97, 2.71, 2.24, 2.89, 2.77, 2.86, 2.5, 2.01, 2.99,
2.11, 2.85, 3.47, 3.29, 2.82, 3.03, 2.84, 3.44, 1.86, 3.58,
3.13, 3.2, 1.6, 2.29, 3.05)The printing time (X) and the packing time (Y) of a T-shirt are uniform on (0, 1) minutes and independent. Find the distribution of . Mark yourself with the criteria.
Solution
Marking criteria:
- Introduces an auxiliary variable (for example ) and writes the inverse 1.0
- Computes the Jacobian and its absolute value 1.0
- Writes the joint density of (U, V) and its support (drawn) 1.5
- Integrates out V piece by piece and reaches : 2.0
- Checks that integrates to 1 (or draws its shape) 0.5
With : , and where and . The range of has length if and if : a triangle peaking at 1.
Check of the above: give and .
Solution
- f_U(1.5) 0.50
- P(U ≤ 0.5) 0.13
With R
fU <- function(u) integrate(function(v) dunif(u - v) * dunif(v), max(0, u - 1), min(1, u))$value c(fU(1.5), integrate(Vectorize(fU), 0, 0.5)$value) # f_U(1.5) and P(U ≤ 0.5) set.seed(5) mean(runif(1e5) + runif(1e5) <= 0.5) # simulating
[1] 0.500 0.125 [1] 0.12964
With the density of the previous part, and . The code integrates the joint density numerically at each point and the simulation gives almost the same.
Each visit to the shop ends in a purchase (1) or not (0): . Let be a simple random sample. Prove that the maximum likelihood estimator of is unbiased, consistent and efficient. Mark yourself with the criteria.
Solution
Marking criteria:
- Writes the log-likelihood, differentiates, sets it to 0 and reaches the MLE: 2.0
- Unbiased: computes of the estimator and gets the parameter 1.5
- Consistent: unbiased and with variance 1.5
- Computes the Fisher information and the bound 1.5
- Concludes it is efficient: its variance attains the bound 0.5
, unbiased, with and equal to the bound.
Check: with and , give the variance of the MLE and the Cramér-Rao bound (with four decimals).
Solution
- Var(MLE) 0.0048
- CR bound 0.0048
- Efficient? Yes
With R
p <- 0.6; n <- 50 c(p * (1 - p) / n, 1 / (n / (p * (1 - p)))) # Var of the MLE and Cramér-Rao bound set.seed(3); e <- replicate(10000, mean(rbinom(n, 1, p))) c(mean(e), var(e)) # simulating: mean and variance of the MLE
[1] 0.0048 0.0048 [1] 0.599974000 0.004840363
and the bound : they match, so it is efficient. Simulating 10,000 samples gives an estimator mean almost equal to the parameter (unbiased) and a variance almost equal to the bound.
The load time (in seconds) of 25 pages of the shop was measured. The data are already in the before vector of your script.
Assuming normal data with and unknown, give a maximum likelihood estimate of each parameter and a 95% confidence interval for each one. Use R.
Solution
- μ̂ 3.44
- μ: lower 3.25
- μ: upper 3.63
- σ̂² 0.21
- σ²: lower 0.13
- σ²: upper 0.42
With R
before <- c(2.85, 3.57, 3.82, 2.97, 3.95, 3.19, 3.64, 3.68, 2.91, 3.34,
3.28, 3.95, 3.97, 3.83, 3.52, 3.28, 3.26, 3.72, 2.71, 3.97,
4.11, 3.87, 2.32, 3.05, 3.28)
after <- c(2.72, 2.97, 2.71, 2.24, 2.89, 2.77, 2.86, 2.5, 2.01, 2.99,
2.11, 2.85, 3.47, 3.29, 2.82, 3.03, 2.84, 3.44, 1.86, 3.58,
3.13, 3.2, 1.6, 2.29, 3.05)
x <- before; n <- length(x)
c(mean(x), t.test(x, conf.level = 0.95)$conf.int) # μ: estimate and interval
s2 <- var(x); a <- 0.05
c((n - 1) * s2 / n, (n - 1) * s2 / qchisq(1 - a / 2, n - 1), (n - 1) * s2 / qchisq(a / 2, n - 1)) # σ²[1] 3.441600 3.249784 3.633416 [1] 0.2073014 0.1316565 0.4179077
; its interval, with the t: . The MLE of divides by n: ; its interval, with the chi-squared: , which is not symmetric.
After compressing the images, the same 25 pages are measured again. The data are in after, in the same order. With R, give a 95% interval for the variance ratio . Can they be assumed equal?
Solution
- Lower 0.37
- Upper 1.88
- Equal variances? Yes
With R
c(var.test(before, after, conf.level = 0.95)$conf.int) # σ²(before) / σ²(after)
[1] 0.365343 1.881378
With Snedecor’s F, the interval is . It contains 1, so there is no reason to say the variances are different.
Assume two paired normal samples and , and let with mean . Prove that follows a Student’s t with degrees of freedom. Mark yourself with the criteria.
Solution
Marking criteria:
- The are independent normals (linear combination of normals; each pair is subtracted inside) 0.75
- 0.75
- , independent of (Fisher) 0.75
- Divides the normal by : cancels and a remains 0.75
The key to paired data is that there are not two samples: there is one, the differences. From there it is the one-sample t, which is why the degrees of freedom are and not .
With the above, give a maximum likelihood estimate of the mean difference and a 99% interval. Interpret it. Use R.
Solution
- d̄ -0.67
- Lower -0.85
- Upper -0.50
- Is there a change? Yes
With R
d <- after - before c(mean(d), t.test(after, before, paired = TRUE, conf.level = 0.99)$conf.int)
[1] -0.672800 -0.850404 -0.495196
They are the same units measured twice, so you work with the differences: and the paired interval is . It does not contain 0: there is a real change, downwards.
The parts are linked: each one often needs the one before.
Data for part 4.e:
amounts <- c(3.57, 2.1, 27.82, 16.05, 4.99, 2.11, 6.94, 2.75, 3.09, 2.73,
2.23, 8.97, 2.96, 2.88, 2.86)The amounts (in tens of euros) of the large orders, those over 2 tens. They are modelled with a population with density , with unknown (and known). Let be a simple random sample. Prove that the maximum likelihood estimator is .
Solution
Marking criteria:
- Writes the log-likelihood 1.25
- Differentiates with respect to the parameter and sets it to 0 1.25
- Solves for the estimator 1.25
- Checks it is a maximum (negative second derivative) 1.25
The logarithm turns the product into a sum; differentiating and setting to 0 gives , and the second derivative is negative.
Find the distribution of .
Solution
Marking criteria:
- Sees each term is exponential (change of variable) 1.6667
- Uses the mgf: the sum’s is the product (independence) 1.6667
- Recognises the mgf of a gamma with shape n 1.6666
Result: .
Find the distribution of .
Solution
Check with R
n <- 15; set.seed(4) u <- replicate(10000, 2 * 1.5 * sum(rexp(n, 1.5))) # U with any parameter value c(mean(u), var(u), 2 * n, 4 * n) # mean and variance: those of a chi-squared with 2n df
[1] 30.12315 60.48300 30.00000 60.00000
Marking criteria:
- Change of variable (or mgf) from the previous part 1.6667
- Reaches: 2.5
- States it does not depend on the parameter: it is a pivot 0.8333
: its distribution does not depend on the parameter, so it works as a pivot. The simulation checks it with an arbitrary parameter value.
With that pivot, build a confidence interval of level for .
Solution
Marking criteria:
- Sets with the pivot’s quantiles 1.6667
- Solves for the parameter inside the probability 1.6667
- Reaches: 1.6666
Interval: .
15 large orders were recorded. They are in the amounts vector of your script. With R, give the estimate of and the 95% interval.
Solution
- Estimate 1.32
- Lower 0.74
- Upper 2.07
With R
amounts <- c(3.57, 2.1, 27.82, 16.05, 4.99, 2.11, 6.94, 2.75, 3.09, 2.73,
2.23, 8.97, 2.96, 2.88, 2.86)
x <- amounts; n <- length(x); a <- 0.05
T <- sum(log(x / 2))
c(n / T, qchisq(a / 2, 2 * n) / (2 * T), qchisq(1 - a / 2, 2 * n) / (2 * T)) # estimate, lower and upper limit[1] 1.3222911 0.7400763 2.0706744
With : estimate 1.32 and interval .
It adds up separately: up to 10 more points, on top of the 100.
Let and . Using only the moment generating function of X, find .
Solution
- E(eˣ) 5.06
With R
(3 / (3 - 1))^4 # with the mgf set.seed(1) mean(exp(rgamma(1e6, 4, 3))) # simulating: almost the same
[1] 5.0625 [1] 5.066583
(it exists because ). It is 5.06.
Let and , all independent. With R, find such that .
Solution
- a 3.69
With R
# W = [Σ(Xi - 1)² / 5] / [Σ(Yj / 3)² / 8] ~ F(5, 8); P(W >= a) = 0.05 qf(0.95, 5, 8)
[1] 3.687499
On top, a over 5; below, a over 8: it is an . Leaving 0.05 on the right is its 0.95 quantile. You get .
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Let A = «the lift is under maintenance» and B = «there is a queue at the laundry» be two independent events, with and . Find from A and B and compare it with . Are and independent?
Solution
- P(Aᶜ ∩ B) 0.32
- P(Aᶜ)·P(B) 0.32
- Independent? Yes
With R
pa <- 0.1; pb <- 0.35 pb - pa * pb # P(Ac ∩ B) = P(B) - P(A ∩ B) (1 - pa) * pb # the product of their probabilities
[1] 0.315 [1] 0.315
Since and split B, , and . They match, so they are independent: it is not a coincidence of these numbers, it is what you prove in the next part.
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.75
- Solves 0.75
- Uses the independence of A and B 0.75
- Reaches 0.75
The idea is always the same: split the event into disjoint pieces (or go to the complement with De Morgan), solve for the intersection you need and plug in independence. In the exam, write the property you use at each step: that is what earns the marks.
Let X be the fraction of the day the halls’ wifi is saturated, a continuous variable on (0, 1) with density for (and 0 elsewhere). Find K so that f is a density.
Solution
- K 0.75
With R
g <- function(x) x^2 + 2 * x # the density without K K <- 1 / integrate(g, 0, 1)$value K
[1] 0.75
, so (0.7500 as a decimal). A density cannot be negative anywhere, and here it is not.
Find the mean and the variance of X.
Solution
- E(X) 0.69
- Var(X) 0.05
With R
f <- function(x) K * g(x) EX <- integrate(function(x) x * f(x), 0, 1)$value VX <- integrate(function(x) x^2 * f(x), 0, 1)$value - EX^2 c(EX, VX)
[1] 0.68750000 0.05234375
and , so . With two decimals: 0.69 and 0.05.
Find the distribution function of X. Check: .
Solution
- F(0.5) 0.22
With R
F <- function(x) integrate(f, 0, x)$value F(0.5)
[1] 0.21875
For , ; if and if . At the check point, .
Using R’s curve function, plot the density f. Mark yourself with the criteria.
Solution
With R
curve(f, 0, 1, lwd = 2, ylab = "f(x)") abline(v = EX, lty = 2) # the mean, to place it
Marking criteria:
- Defines f in R with K and vectorised (it accepts a vector x) 0.5
- Calls
curve(f, 0, 1)(or withfromandto) 0.5 - Describes the shape: starts at 0 and always increases, ever faster, up to 2.25 at 0.5
- Places the mean (and the median of the next part) on the plot 0.5
The curve you should get: starts at 0 and always increases, ever faster, up to 2.25 at . If curve gives a length error, f is not vectorised: with integrate inside it would not be, which is why f is defined with the formula and not with integrals.
With R, find the median of X (for example with uniroot, or with uniroot.all from the rootSolve library).
Solution
- Median 0.73
With R
uniroot(function(x) F(x) - 0.5, c(0.001, 0.999))$root # median: F(x) = 0.5
[1] 0.73205
The median is the x with : 0.73. It is above the mean, because the long tail is on the left.
The halls have three lifts. The time T (in seconds) you wait for one depends on which one comes: «North lift» handles 40% and its time is uniform between 0 and 60; «South lift» handles 35% and its time is exponential with mean 30; «Service lift» handles 25% and its time is gamma with shape 3 and rate 0.1 (mean 30). Find the probability that you wait 20 seconds or less, .
Solution
- P(T ≤ 20) 0.38
With R
t <- 20
P <- c(0.4 * punif(t, 0, 60),
0.35 * pexp(t, 1/30),
0.25 * pgamma(t, 3, 0.1))
sum(P) # P(T <= 20)[1] 0.3844682
By total probability: , each conditional probability coming from its model. It gives 0.38.
Given that you wait 20 seconds or less, use R to find the probability that each one handled it.
Solution
- North lift 0.35
- South lift 0.44
- Service lift 0.21
With R
P / sum(P) # P(source | T <= 20)
[1] 0.3467993 0.4429599 0.2102408
Bayes: ; each term of the previous part over the total. You get 0.35, 0.44, 0.21, which add up to 1.
It has 2 independent parts (2.1, 2.2…); within each one, a part often needs the one before.
Data for part 2.1.a:
parcels <- c(3, 2, 4, 2, 0, 3, 1, 1, 0, 2,
4, 2, 2, 4, 2, 0, 0, 0, 0, 3,
1, 2, 1, 2, 2, 4, 0, 2, 3, 2,
1, 3, 1, 1, 3, 1, 2, 1, 0, 3)X is the number of parcels that arrive each day at the halls’ front desk. It is assumed to follow a Poisson , with . The data for 40 days are in the parcels vector of your script.
Two ways to estimate : (1) set the model mean equal to the sample mean and (2) set the model variance equal to the sample variance. With R, find by both methods and compare them.
Solution
- Method 1 1.75
- Method 2 1.58
With R
parcels <- c(3, 2, 4, 2, 0, 3, 1, 1, 0, 2,
4, 2, 2, 4, 2, 0, 0, 0, 0, 3,
1, 2, 1, 2, 2, 4, 0, 2, 3, 2,
1, 3, 1, 1, 3, 1, 2, 1, 0, 3)
x <- parcels; m <- mean(x); s2 <- var(x)
l1 <- m # mean: λ = sample mean
l2 <- s2 # variance: λ = sample variance
c(m, s2, l1, l2)[1] 1.750000 1.576923 1.750000 1.576923
In the Poisson the mean and the variance are both λ, so (1) gives and (2) . If the data were Poisson, the sample mean and variance would be close; here the variance is smaller than the mean.
With R and for each method, find the probability of exactly one parcel, , and of between 2 and 4, .
Solution
- P(X = 1), meth. 1 0.30
- P(2 ≤ X ≤ 4), meth. 1 0.49
- P(X = 1), meth. 2 0.33
- P(2 ≤ X ≤ 4), meth. 2 0.45
With R
c(dpois(1, l1), ppois(4, l1) - ppois(1, l1)) # method 1: P(X = 1), P(2 <= X <= 4) c(dpois(1, l2), ppois(4, l2) - ppois(1, l2)) # method 2
[1] 0.3041044 0.4892200 [1] 0.3258078 0.4451504
is the mass at 1 (dpois) and (ppois): careful, would leave out the 2. Method 1: 0.30 and 0.49; method 2: 0.33 and 0.45.
With R, build the table of observed frequencies (classes 0, 1, 2, 3 and 4 or more) and the expected ones under each method, and draw them together with barplot. Comment. Mark yourself with the criteria.
Solution
With R
O <- table(cut(x, c(-1, 0, 1, 2, 3, Inf), labels = c("0", "1", "2", "3", "4+")))
n <- length(x)
E1 <- n * c(dpois(0:3, l1), 1 - ppois(3, l1))
E2 <- n * c(dpois(0:3, l2), 1 - ppois(3, l2))
round(rbind(O, E1, E2), 2)
barplot(rbind(O, E1, E2), beside = TRUE, legend.text = c("Observed", "Mean", "Variance"))0 1 2 3 4+ O 8.00 9.00 12.00 7.00 4.00 E1 6.95 12.16 10.64 6.21 4.03 E2 8.26 13.03 10.28 5.40 3.03
Marking criteria:
- Observed table with the five classes (the last one, «4 or more») 0.25
- Expected = n · probability of each class, with the tail in the last one 0.25
barplotwithbeside = TRUEand a legend 0.25- Comments on the classes where each model departs from the data 0.25
The expected frequencies must add up to n, like the observed ones: that is why the last class is «4 or more» (the tail), not «4». Look at the output: the two models split the frequency differently between 0 and the high classes.
To choose a model you use , with the classes of the previous part; the smaller value is preferred. Compute it for both methods and choose.
Solution
- χ² method 1 1.26
- χ² method 2 2.33
- I choose Method 1 (mean)
With R
c(sum((O - E1)^2 / E1), sum((O - E2)^2 / E2))
[1] 1.255323 2.331824
is 1.26 with method 1 and 2.33 with method 2: method 1 wins. It is a distance between what was observed and what was expected, each squared difference relative to what was expected.
The porter logs each parcel in an exponential time with mean 1.2 minutes, independent of the others. Let T be the time he takes to log the morning’s 10 parcels. Explain which distribution T follows and give its parameters.
Solution
- Shape 10
- Rate λ 0.83
With R
n <- 10; la <- 1 / 1.2 c(n, la) # T ~ gamma(shape n, rate λ)
[1] 10.0000000 0.8333333
T is the sum of 10 independent exponentials with rate (mean 1.2 minutes). Each one’s mgf is and the sum’s is the product, , which is a gamma’s: , with mean 12 minutes.
With R, find the probability that he logs them in under 15 minutes.
Solution
- P(T < 15) 0.80
With R
pgamma(15, shape = n, rate = la) # P(T < 15)
[1] 0.7985689
pgamma(15, shape = 10, rate = λ) = 0.80.
With R, find the 90th percentile of T and interpret it.
Solution
- 0.90 quantile 17.05
With R
qgamma(0.9, shape = n, rate = la)
[1] 17.04719
qgamma(0.9, 10, λ) = 17.05: 90% of the time T does not exceed 17.05 minutes (and one in ten times it does).
The parts are linked: each one often needs the one before.
Let X be the number of flatmates who join you to cook on a Saturday (at most two). Its mass function is , for (only those three values), with . Find K so that is a mass function for every value of the parameter.
Solution
Check with R
la <- 1; x <- 0:2 # check value and many terms fx <- la^x / factorial(x) / (1 + la + la^2 / 2) sum(fx) # 1
[1] 1
Marking criteria:
- Checks that no term is negative 1.0
- Recognises the sum: a finite sum of three terms, 2.0
- Solves 1.0
- States for which parameter values it holds (all those in the statement) 1.0
Two things: no term is negative and they add up to 1. The sum is a finite sum of three terms, , so . In R you check it by adding many terms for a specific parameter value (the code adds up to 1 with ).
Find the moment generating function . Check: with , give and .
Solution
- φ(0.5) 1.60
- P(X = 1) 0.40
With R
t <- 0.5 c(sum(exp(t * x) * fx), (1 + la * exp(t) + la^2 * exp(2 * t) / 2) / (1 + la + la^2 / 2), fx[x == 1]) # φ(0.5) with sums and with the formula; P(X = 1)
[1] 1.603145 1.603145 0.400000
Put inside the sum and group it with the power of the parameter: you get the same sum as in the previous part with another argument, , for every t. With : and .
Find . Check: its value with .
Solution
- E(X) 0.80
With R
c(sum(x * fx), (la + la^2) / (1 + la + la^2 / 2)) # E(X) with sums and with the formula
[1] 0.8 0.8
Differentiating the mgf at 0 (or summing directly): . With , 0.80. The code checks it with a long sum.
It adds up separately: up to 2.5 more points, on top of the 50.
Let and . Using only the moment generating function of X, find .
Solution
- E(e^(X/6)) 3.38
With R
(1 - 2 / 6)^(-6 / 2) # with the mgf set.seed(1) mean(exp(rchisq(1e6, 6) / 6)) # simulating: almost the same
[1] 3.375 [1] 3.375818
The chi-squared with 6 df is a gamma(3, 1/2), with for . . It is 3.38.
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Let be the time (in hours) each of the 36 electric airport carts takes to charge, independent with common density , . Let ; you need . Using R and applying, if possible, the central limit theorem, find the requested probability approximately. Also give the mean and the variance of each .
Solution
- E(Xᵢ) 1.33
- Var(Xᵢ) 0.06
- P(S ≤ 49) 0.76
With R
f <- function(x) 2 * (2 - x) mu <- integrate(function(x) x * f(x), 1, 2)$value s2 <- integrate(function(x) x^2 * f(x), 1, 2)$value - mu^2 n <- 36 c(mu, s2, pnorm(49, n * mu, sqrt(n * s2))) # P(S <= 49) by the CLT
[1] 1.33333333 0.05555556 0.76024994
and (finite, so the CLT applies). With , and the requested probability is 0.76.
The delays X and Y (in hours) of two flights due at the same time are exponential with mean 1, independent. Find the distribution of . Mark yourself with the criteria.
Solution
Marking criteria:
- Introduces an auxiliary variable (for example ) and writes the inverse 1.0
- Computes the Jacobian and its absolute value 1.0
- Writes the joint density of (U, V) and its support (drawn) 1.5
- Integrates out V piece by piece and reaches : 2.0
- Checks that integrates to 1 (or draws its shape) 0.5
With : for and . If , runs from 0 to and you get ; if , from to and you get : the Laplace, .
Check of the above: give and .
Solution
- f_U(1) 0.18
- P(|U| < 1) 0.63
With R
fU <- function(u) integrate(function(v) dexp(u + v) * dexp(v), max(0, -u), Inf)$value c(fU(1), integrate(Vectorize(fU), -1, 1)$value) # f_U(1) and P(|U| < 1) set.seed(5) mean(abs(rexp(1e5) - rexp(1e5)) < 1) # simulating
[1] 0.1839397 0.6321206 [1] 0.63228
With the density of the previous part, and . The code integrates the joint density numerically at each point and the simulation gives almost the same.
The waiting minutes at the security check are exponential with mean : , . Let be a simple random sample. Prove that the maximum likelihood estimator of is unbiased, consistent and efficient. Mark yourself with the criteria.
Solution
Marking criteria:
- Writes the log-likelihood, differentiates, sets it to 0 and reaches the MLE: 2.0
- Unbiased: computes of the estimator and gets the parameter 1.5
- Consistent: unbiased and with variance 1.5
- Computes the Fisher information and the bound 1.5
- Concludes it is efficient: its variance attains the bound 0.5
gives ; , ; and the bound is .
Check: with and , give the variance of the MLE and the Cramér-Rao bound (with four decimals).
Solution
- Var(MLE) 0.6250
- CR bound 0.6250
- Efficient? Yes
With R
th <- 5; n <- 40 c(th^2 / n, 1 / (n / th^2)) # Var of the MLE and Cramér-Rao bound set.seed(3); e <- replicate(10000, mean(rexp(n, 1 / th))) c(mean(e), var(e)) # simulating: mean and variance of the MLE
[1] 0.625 0.625 [1] 4.9998856 0.6419839
and the bound : they match, so it is efficient. Simulating 10,000 samples gives an estimator mean almost equal to the parameter (unbiased) and a variance almost equal to the bound.
The parts are linked: each one often needs the one before.
Data for part 2.a:
home <- c(19, 18.1, 17.2, 22.9, 20, 16.8, 18, 16.4, 17.4, 18.9,
24.6, 17.2, 21.7, 17.1, 20.2, 18.8, 19.3, 20.7, 18.6, 15.9,
18.3, 16.8, 20.2, 15.7, 18.6)Data for part 2.b:
desk <- c(18.7, 18.6, 17.5, 22.9, 19.5, 16.7, 17.8, 16.4, 17.8, 18.9,
24.3, 16, 21.7, 17, 20.7, 18.6, 19.5, 21.2, 18.7, 16.6,
18.7, 17.4, 20.5, 15.9, 19)25 travellers weigh their suitcase at home with their scale (in kg). The data are already in the home vector of your script.
Assuming normal data with and unknown, give a maximum likelihood estimate of each parameter and a 90% confidence interval for each one. Use R.
Solution
- μ̂ 18.74
- μ: lower 18.00
- μ: upper 19.47
- σ̂² 4.45
- σ²: lower 3.05
- σ²: upper 8.03
With R
home <- c(19, 18.1, 17.2, 22.9, 20, 16.8, 18, 16.4, 17.4, 18.9,
24.6, 17.2, 21.7, 17.1, 20.2, 18.8, 19.3, 20.7, 18.6, 15.9,
18.3, 16.8, 20.2, 15.7, 18.6)
desk <- c(18.7, 18.6, 17.5, 22.9, 19.5, 16.7, 17.8, 16.4, 17.8, 18.9,
24.3, 16, 21.7, 17, 20.7, 18.6, 19.5, 21.2, 18.7, 16.6,
18.7, 17.4, 20.5, 15.9, 19)
x <- home; n <- length(x)
c(mean(x), t.test(x, conf.level = 0.9)$conf.int) # μ: estimate and interval
s2 <- var(x); a <- 0.1
c((n - 1) * s2 / n, (n - 1) * s2 / qchisq(1 - a / 2, n - 1), (n - 1) * s2 / qchisq(a / 2, n - 1)) # σ²[1] 18.73600 17.99933 19.47267 [1] 4.449504 3.054717 8.032509
; its interval, with the t: . The MLE of divides by n: ; its interval, with the chi-squared: , which is not symmetric.
The same 25 suitcases are weighed afterwards at the check-in desk. The data are in desk, in the same order. With R, give a 95% interval for the variance ratio . Can they be assumed equal?
Solution
- Lower 0.45
- Upper 2.32
- Equal variances? Yes
With R
c(var.test(home, desk, conf.level = 0.95)$conf.int) # σ²(home) / σ²(desk)
[1] 0.4496921 2.3157430
With Snedecor’s F, the interval is . It contains 1, so there is no reason to say the variances are different.
Assume two paired normal samples and , and let with mean . Prove that follows a Student’s t with degrees of freedom. Mark yourself with the criteria.
Solution
Marking criteria:
- The are independent normals (linear combination of normals; each pair is subtracted inside) 0.75
- 0.75
- , independent of (Fisher) 0.75
- Divides the normal by : cancels and a remains 0.75
The key to paired data is that there are not two samples: there is one, the differences. From there it is the one-sample t, which is why the degrees of freedom are and not .
With the above, give a maximum likelihood estimate of the mean difference and a 95% interval. Interpret it. Use R.
Solution
- d̄ 0.09
- Lower -0.08
- Upper 0.26
- Is there a change? No
With R
d <- desk - home c(mean(d), t.test(desk, home, paired = TRUE, conf.level = 0.95)$conf.int)
[1] 0.08800000 -0.08315847 0.25915847
They are the same units measured twice, so you work with the differences: and the paired interval is . It contains 0: with these data you cannot say there is a change.
The parts are linked: each one often needs the one before.
Data for part 3.e:
boarding <- c(2.73, 1.86, 3.05, 3.46, 1.53, 1.5, 1.48, 1.1, 3.33, 2.98,
2.62, 1.18, 3.47, 2.96)The minutes each passenger of a flight takes to board, which never go below 1 minute. They are modelled with a population with density , with unknown (and known). Let be a simple random sample. Prove that the maximum likelihood estimator is .
Solution
Marking criteria:
- Writes the log-likelihood 0.75
- Differentiates with respect to the parameter and sets it to 0 0.75
- Solves for the estimator 0.75
- Checks it is a maximum (negative second derivative) 0.75
The logarithm turns the product into a sum; differentiating and setting to 0 gives , and the second derivative is negative.
Find the distribution of .
Solution
Marking criteria:
- Sees each term is exponential (change of variable) 1.0
- Uses the mgf: the sum’s is the product (independence) 1.0
- Recognises the mgf of a gamma with shape n 1.0
Result: .
Find the distribution of .
Solution
Check with R
n <- 14; set.seed(4) u <- replicate(10000, 2 * 1.5 * sum(rexp(n, 1.5))) # U with any parameter value c(mean(u), var(u), 2 * n, 4 * n) # mean and variance: those of a chi-squared with 2n df
[1] 28.12708 57.36497 28.00000 56.00000
Marking criteria:
- Change of variable (or mgf) from the previous part 1.0
- Reaches: 1.5
- States it does not depend on the parameter: it is a pivot 0.5
: its distribution does not depend on the parameter, so it works as a pivot. The simulation checks it with an arbitrary parameter value.
With that pivot, build a confidence interval of level for .
Solution
Marking criteria:
- Sets with the pivot’s quantiles 1.0
- Solves for the parameter inside the probability 1.0
- Reaches: 1.0
Interval: .
14 passengers were timed. They are in the boarding vector of your script. With R, give the estimate of and the 90% interval.
Solution
- Estimate 0.73
- Lower 0.44
- Upper 1.07
With R
boarding <- c(2.73, 1.86, 3.05, 3.46, 1.53, 1.5, 1.48, 1.1, 3.33, 2.98,
2.62, 1.18, 3.47, 2.96)
x <- boarding; n <- length(x); a <- 0.1
T <- sum(x - 1)
c(n / T, qchisq(a / 2, 2 * n) / (2 * T), qchisq(1 - a / 2, 2 * n) / (2 * T)) # estimate, lower and upper limit[1] 0.7272727 0.4396851 1.0736919
With : estimate 0.727 and interval .
It adds up separately: up to 5 more points, on top of the 50.
The last 25 flights of two airlines are compared: 1 if on time and 0 if not.
First: c(1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1)
Second: c(0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1)
With R, give a maximum likelihood estimate of each proportion and of their difference.
Solution
- p̂₁ 0.76
- p̂₂ 0.56
- p̂₁ − p̂₂ 0.20
With R
x <- c(1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1) y <- c(0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1) p1 <- mean(x); p2 <- mean(y) c(p1, p2, p1 - p2)
[1] 0.76 0.56 0.20
The MLE of a proportion is the sample proportion: 0.76 and 0.56; the difference, 0.20.
Give a 90% asymptotic confidence interval for . Are they different?
Solution
- Lower -0.02
- Upper 0.42
- Different? No
With R
m <- length(x); n <- length(y); z <- qnorm(0.95) (p1 - p2) + c(-1, 1) * z * sqrt(p1 * (1 - p1) / m + p2 * (1 - p2) / n)
[1] -0.01541932 0.41541932
. It contains 0: you cannot say they are different.
Let be independent, with mean and sample variance . With R, find such that .
Solution
- a 2.20
With R
# T = (X̄ - 10) / (S / sqrt(12)) ~ t(11); P(|T| <= a) = 0.95 qt(0.975, 11)
[1] 2.200985
The ratio is a , symmetric: leaving 0.95 in the middle means 0.025 in each tail, so is the 0.975 quantile. You get .
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Data for part 1.3.a:
fouls <- c(1, 0, 1, 2, 1, 0, 0, 1, 2, 6,
0, 1, 0, 2, 3, 3, 0, 0, 0, 1,
3, 3, 1, 4, 0, 3, 0, 1, 1, 0,
0, 0, 1, 1, 1, 0, 0, 0, 0, 1)Let A = «it rains on training day» and B = «the coach changes the session» be two independent events, with and . Find from A and B and compare it with . Are and independent?
Solution
- P(Aᶜ ∩ B) 0.34
- P(Aᶜ)·P(B) 0.34
- Independent? Yes
With R
pa <- 0.15; pb <- 0.4 pb - pa * pb # P(Ac ∩ B) = P(B) - P(A ∩ B) (1 - pa) * pb # the product of their probabilities
[1] 0.34 [1] 0.34
Since and split B, , and . They match, so they are independent: it is not a coincidence of these numbers, it is what you prove in the next part.
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.75
- Solves 0.75
- Uses the independence of A and B 0.75
- Reaches 0.75
The idea is always the same: split the event into disjoint pieces (or go to the complement with De Morgan), solve for the intersection you need and plug in independence. In the exam, write the property you use at each step: that is what earns the marks.
Let X be the fraction of a track lap an athlete runs before their first change of pace, a continuous variable on (0, 1) with density for (and 0 elsewhere). Find K so that f is a density.
Solution
- K 3.00
With R
g <- function(x) 1 - sqrt(x) # the density without K K <- 1 / integrate(g, 0, 1)$value K
[1] 3.000001
, so (3.0000 as a decimal). A density cannot be negative anywhere, and here it is not.
Find the mean and the variance of X.
Solution
- E(X) 0.30
- Var(X) 0.05
With R
f <- function(x) K * g(x) EX <- integrate(function(x) x * f(x), 0, 1)$value VX <- integrate(function(x) x^2 * f(x), 0, 1)$value - EX^2 c(EX, VX)
[1] 0.30000008 0.05285713
and , so . With two decimals: 0.30 and 0.05.
Find the distribution function of X. Check: .
Solution
- F(0.25) 0.50
With R
F <- function(x) integrate(f, 0, x)$value F(0.25)
[1] 0.5
For , ; if and if . At the check point, .
Using R’s curve function, plot the density f. Mark yourself with the criteria.
Solution
With R
curve(f, 0, 1, lwd = 2, ylab = "f(x)") abline(v = EX, lty = 2) # the mean, to place it
Marking criteria:
- Defines f in R with K and vectorised (it accepts a vector x) 0.5
- Calls
curve(f, 0, 1)(or withfromandto) 0.5 - Describes the shape: is 3 at and falls very fast at first, down to 0 at 0.5
- Places the mean (and the median of the next part) on the plot 0.5
The curve you should get: is 3 at and falls very fast at first, down to 0 at . If curve gives a length error, f is not vectorised: with integrate inside it would not be, which is why f is defined with the formula and not with integrals.
With R, find the median of X (for example with uniroot, or with uniroot.all from the rootSolve library).
Solution
- Median 0.25
With R
uniroot(function(x) F(x) - 0.5, c(0.001, 0.999))$root # median: F(x) = 0.5
[1] 0.2500022
The median is the x with : 0.25. It is below the mean, because the long tail is on the right.
X is the number of false starts before the first valid one in each day’s sprint heats. It is assumed to follow a geometric (number of failures before the first success), with and . The data for 40 days are in the fouls vector of your script.
Two ways to estimate : (1) set the model mean equal to the sample mean and (2) set the model variance equal to the sample variance. With R, find by both methods and compare them.
Solution
- Method 1 0.48
- Method 2 0.51
With R
fouls <- c(1, 0, 1, 2, 1, 0, 0, 1, 2, 6,
0, 1, 0, 2, 3, 3, 0, 0, 0, 1,
3, 3, 1, 4, 0, 3, 0, 1, 1, 0,
0, 0, 1, 1, 1, 0, 0, 0, 0, 1)
x <- fouls; m <- mean(x); s2 <- var(x)
p1 <- 1 / (1 + m) # mean: (1 - p)/p = sample mean
p2 <- (-1 + sqrt(1 + 4 * s2)) / (2 * s2) # variance: (1 - p)/p^2 = sample variance
c(m, s2, p1, p2)[1] 1.1000000 1.8871795 0.4761905 0.5097075
Sample mean 1.10 and sample variance 1.89. (1) gives . (2) is the quadratic , whose positive root is . If the model were perfect, the two would be very close; the further apart they are, the more suspicious the model.
With R and for each method, find the probability of exactly one false start, , and of between 2 and 4, .
Solution
- P(X = 1), meth. 1 0.25
- P(2 ≤ X ≤ 4), meth. 1 0.23
- P(X = 1), meth. 2 0.25
- P(2 ≤ X ≤ 4), meth. 2 0.21
With R
c(dgeom(1, p1), pgeom(4, p1) - pgeom(1, p1)) # method 1: P(X = 1), P(2 <= X <= 4) c(dgeom(1, p2), pgeom(4, p2) - pgeom(1, p2)) # method 2
[1] 0.2494331 0.2349428 [1] 0.2499058 0.2120548
is the mass at 1 (dgeom) and (pgeom): careful, would leave out the 2. Method 1: 0.25 and 0.23; method 2: 0.25 and 0.21.
With R, build the table of observed frequencies (classes 0, 1, 2, 3 and 4 or more) and the expected ones under each method, and draw them together with barplot. Comment. Mark yourself with the criteria.
Solution
With R
O <- table(cut(x, c(-1, 0, 1, 2, 3, Inf), labels = c("0", "1", "2", "3", "4+")))
n <- length(x)
E1 <- n * c(dgeom(0:3, p1), 1 - pgeom(3, p1))
E2 <- n * c(dgeom(0:3, p2), 1 - pgeom(3, p2))
round(rbind(O, E1, E2), 2)
barplot(rbind(O, E1, E2), beside = TRUE, legend.text = c("Observed", "Mean", "Variance"))0 1 2 3 4+ O 17.00 13.00 3.00 5.00 2.00 E1 19.05 9.98 5.23 2.74 3.01 E2 20.39 10.00 4.90 2.40 2.31
Marking criteria:
- Observed table with the five classes (the last one, «4 or more») 0.5
- Expected = n · probability of each class, with the tail in the last one 0.5
barplotwithbeside = TRUEand a legend 0.5- Comments on the classes where each model departs from the data 0.5
The expected frequencies must add up to n, like the observed ones: that is why the last class is «4 or more» (the tail), not «4». Look at the output: the two models split the frequency differently between 0 and the high classes.
To choose a model you use , with the classes of the previous part; the smaller value is preferred. Compute it for both methods and choose.
Solution
- χ² method 1 4.29
- χ² method 2 5.05
- I choose Method 1 (mean)
With R
c(sum((O - E1)^2 / E1), sum((O - E2)^2 / E2))
[1] 4.293606 5.051859
is 4.29 with method 1 and 5.05 with method 2: method 1 wins. It is a distance between what was observed and what was expected, each squared difference relative to what was expected.
It has 2 independent parts (2.1, 2.2…); within each one, a part often needs the one before.
The number N of members who come to the track on a Tuesday follows a Poisson with mean 25. Using Chebyshev’s inequality, find a lower bound for .
Solution
- Lower bound 0.75
With R
la <- 25; k <- 10 1 - la / k^2 # Chebyshev bound
[1] 0.75
and . The interval is , so .
Using R, compare with the exact value.
Solution
- Exact 0.97
With R
ppois(35, la) - ppois(14, la) # exact
[1] 0.9651399
The exact value is 0.97, much more than the bound 0.75: Chebyshev holds for any distribution, which is why it falls short.
Let X be the number of race bibs lost at a fun run. Its mass function is , for , with . Find K so that is a mass function for every value of the parameter.
Solution
Check with R
la <- 2; x <- 0:100 # check value and many terms fx <- exp(-la) / (la * (1 + la)) * x^2 * la^x / factorial(x) sum(fx) # 1
[1] 1
Marking criteria:
- Checks that no term is negative 1.0
- Recognises the sum: the exponential series’ second moment, 2.0
- Solves 1.0
- States for which parameter values it holds (all those in the statement) 1.0
Two things: no term is negative and they add up to 1. The sum is the exponential series’ second moment, , so . In R you check it by adding many terms for a specific parameter value (the code adds up to 1 with ).
Find the moment generating function . Check: with , give and .
Solution
- φ(0.1) 1.46
- P(X = 1) 0.05
With R
t <- 0.1 c(sum(exp(t * x) * fx), exp(la * (exp(t) - 1)) * exp(t) * (1 + la * exp(t)) / (1 + la), fx[x == 1]) # φ(0.1) with sums and with the formula; P(X = 1)
[1] 1.45951906 1.45951906 0.04511176
Put inside the sum and group it with the power of the parameter: you get the same sum as in the previous part with another argument, , for every t. With : and .
Find . Check: its value with .
Solution
- E(X) 3.67
With R
c(sum(x * fx), la + 1 + la / (1 + la)) # E(X) with sums and with the formula
[1] 3.666667 3.666667
Differentiating the mgf at 0 (or summing directly): . With , 3.67. The code checks it with a long sum.
It has 3 independent parts (3.1, 3.2…); within each one, a part often needs the one before.
Data for part 3.3.a:
before <- c(56.8, 60.6, 57.9, 57.6, 60.2, 58.4, 59, 57.7, 61.9, 59.7,
56.8, 57.5, 58.3, 58.2, 58, 56.8, 61.7, 59.2, 59.7, 62.2,
61.6, 56.8, 61.6, 57, 57.7)Data for part 3.3.b:
after <- c(56.8, 57.8, 57.4, 56.7, 58.6, 57.7, 57.4, 55.8, 62.8, 57.4,
54.8, 56.1, 58.7, 58.7, 57.4, 53.2, 61.8, 57.9, 58.2, 60.3,
62.9, 56.1, 61.5, 56.7, 57)An athlete reaches the track at a time and the coach at , independent (in hours from 17:00). Find the distribution of . Mark yourself with the criteria.
Solution
Marking criteria:
- Introduces an auxiliary variable (for example ) and writes the inverse 1.0
- Computes the Jacobian and its absolute value 1.0
- Writes the joint density of (U, V) and its support (drawn) 1.5
- Integrates out V piece by piece and reaches : 2.0
- Checks that integrates to 1 (or draws its shape) 0.5
With : where and . The range of has length , 1 or : a trapezoid from to 3.
Check of the above: give and .
Solution
- f_U(2.5) 0.17
- P(U < 0) 0.17
With R
fU <- function(u) integrate(function(v) dunif(u + v, 0, 3) * dunif(v), max(0, -u), min(1, 3 - u))$value c(fU(2.5), integrate(Vectorize(fU), -1, 0)$value) # f_U(2.5) and P(U < 0) set.seed(5) mean(runif(1e5, 0, 3) - runif(1e5) < 0) # simulating
[1] 0.1666667 0.1666667 [1] 0.16784
With the density of the previous part, and . The code integrates the joint density numerically at each point and the simulation gives almost the same.
The time (in minutes) between two athletes crossing the line in a free training session is exponential with mean . Let be a simple random sample. Prove that the maximum likelihood estimator of is unbiased, consistent and efficient. Mark yourself with the criteria.
Solution
Marking criteria:
- Writes the log-likelihood, differentiates, sets it to 0 and reaches the MLE: 2.0
- Unbiased: computes of the estimator and gets the parameter 1.5
- Consistent: unbiased and with variance 1.5
- Computes the Fisher information and the bound 1.5
- Concludes it is efficient: its variance attains the bound 0.5
, unbiased, with and equal to the bound .
Check: with and , give the variance of the MLE and the Cramér-Rao bound (with four decimals).
Solution
- Var(MLE) 0.2500
- CR bound 0.2500
- Efficient? Yes
With R
th <- 3; n <- 36 c(th^2 / n, 1 / (n / th^2)) # Var of the MLE and Cramér-Rao bound set.seed(3); e <- replicate(10000, mean(rexp(n, 1 / th))) c(mean(e), var(e)) # simulating: mean and variance of the MLE
[1] 0.25 0.25 [1] 2.9996617 0.2565111
and the bound : they match, so it is efficient. Simulating 10,000 samples gives an estimator mean almost equal to the parameter (unbiased) and a variance almost equal to the bound.
The 400 m times (in seconds) of 25 club athletes were measured. The data are already in the before vector of your script.
Assuming normal data with and unknown, give a maximum likelihood estimate of each parameter and a 90% confidence interval for each one. Use R.
Solution
- μ̂ 58.92
- μ: lower 58.30
- μ: upper 59.54
- σ̂² 3.16
- σ²: lower 2.17
- σ²: upper 5.70
With R
before <- c(56.8, 60.6, 57.9, 57.6, 60.2, 58.4, 59, 57.7, 61.9, 59.7,
56.8, 57.5, 58.3, 58.2, 58, 56.8, 61.7, 59.2, 59.7, 62.2,
61.6, 56.8, 61.6, 57, 57.7)
after <- c(56.8, 57.8, 57.4, 56.7, 58.6, 57.7, 57.4, 55.8, 62.8, 57.4,
54.8, 56.1, 58.7, 58.7, 57.4, 53.2, 61.8, 57.9, 58.2, 60.3,
62.9, 56.1, 61.5, 56.7, 57)
x <- before; n <- length(x)
c(mean(x), t.test(x, conf.level = 0.9)$conf.int) # μ: estimate and interval
s2 <- var(x); a <- 0.1
c((n - 1) * s2 / n, (n - 1) * s2 / qchisq(1 - a / 2, n - 1), (n - 1) * s2 / qchisq(a / 2, n - 1)) # σ²[1] 58.91600 58.29537 59.53663 [1] 3.158144 2.168160 5.701269
; its interval, with the t: . The MLE of divides by n: ; its interval, with the chi-squared: , which is not symmetric.
After pre-season, the same 25 athletes are timed again. The data are in after, in the same order. With R, give a 90% interval for the variance ratio . Can they be assumed equal?
Solution
- Lower 0.30
- Upper 1.18
- Equal variances? Yes
With R
c(var.test(before, after, conf.level = 0.9)$conf.int) # σ²(before) / σ²(after)
[1] 0.298919 1.176336
With Snedecor’s F, the interval is . It contains 1, so there is no reason to say the variances are different.
Assume two paired normal samples and , and let with mean . Prove that follows a Student’s t with degrees of freedom. Mark yourself with the criteria.
Solution
Marking criteria:
- The are independent normals (linear combination of normals; each pair is subtracted inside) 0.75
- 0.75
- , independent of (Fisher) 0.75
- Divides the normal by : cancels and a remains 0.75
The key to paired data is that there are not two samples: there is one, the differences. From there it is the one-sample t, which is why the degrees of freedom are and not .
With the above, give a maximum likelihood estimate of the mean difference and a 95% interval. Interpret it. Use R.
Solution
- d̄ -0.93
- Lower -1.41
- Upper -0.45
- Is there a change? Yes
With R
d <- after - before c(mean(d), t.test(after, before, paired = TRUE, conf.level = 0.95)$conf.int)
[1] -0.9280000 -1.4098986 -0.4461014
They are the same units measured twice, so you work with the differences: and the paired interval is . It does not contain 0: there is a real change, downwards.
The parts are linked: each one often needs the one before.
Data for part 4.e:
reaction <- c(0.7, 0.85, 0.55, 0.63, 0.81, 2.08, 0.53, 0.64, 0.54, 0.73,
1.12, 0.85)The times (in tenths of a second) an athlete takes to react to the gun, which never go below 0.5. They are modelled with a population with density , with unknown (and known). Let be a simple random sample. Prove that the maximum likelihood estimator is .
Solution
Marking criteria:
- Writes the log-likelihood 1.25
- Differentiates with respect to the parameter and sets it to 0 1.25
- Solves for the estimator 1.25
- Checks it is a maximum (negative second derivative) 1.25
The logarithm turns the product into a sum; differentiating and setting to 0 gives , and the second derivative is negative.
Find the distribution of .
Solution
Marking criteria:
- Sees each term is exponential (change of variable) 1.6667
- Uses the mgf: the sum’s is the product (independence) 1.6667
- Recognises the mgf of a gamma with shape n 1.6666
Result: .
Find the distribution of .
Solution
Check with R
n <- 12; set.seed(4) u <- replicate(10000, 2 * 1.5 * sum(rexp(n, 1.5))) # U with any parameter value c(mean(u), var(u), 2 * n, 4 * n) # mean and variance: those of a chi-squared with 2n df
[1] 24.13396 48.91522 24.00000 48.00000
Marking criteria:
- Change of variable (or mgf) from the previous part 1.6667
- Reaches: 2.5
- States it does not depend on the parameter: it is a pivot 0.8333
: its distribution does not depend on the parameter, so it works as a pivot. The simulation checks it with an arbitrary parameter value.
With that pivot, build a confidence interval of level for .
Solution
Marking criteria:
- Sets with the pivot’s quantiles 1.6667
- Solves for the parameter inside the probability 1.6667
- Reaches: 1.6666
Interval: .
12 starts were measured. They are in the reaction vector of your script. With R, give the estimate of and the 95% interval.
Solution
- Estimate 2.98
- Lower 1.54
- Upper 4.88
With R
reaction <- c(0.7, 0.85, 0.55, 0.63, 0.81, 2.08, 0.53, 0.64, 0.54, 0.73,
1.12, 0.85)
x <- reaction; n <- length(x); a <- 0.05
T <- sum(x - 0.5)
c(n / T, qchisq(a / 2, 2 * n) / (2 * T), qchisq(1 - a / 2, 2 * n) / (2 * T)) # estimate, lower and upper limit[1] 2.977667 1.538604 4.883881
With : estimate 2.98 and interval .
It adds up separately: up to 10 more points, on top of the 100.
Let be exponential with rate 4 and . Using only the moment generating function of X, find .
Solution
- E(eˣ) 1.33
With R
4 / (4 - 1) # with the mgf set.seed(1) mean(exp(rexp(1e6, 4))) # simulating: almost the same
[1] 1.333333 [1] 1.333688
(it exists because ). It is 1.33.
Let be independent, with mean and sample variance . With R, find such that .
Solution
- a 1.75
With R
# T = (X̄ - 7) / (S / sqrt(16)) ~ t(15); P(T >= a) = 0.05 qt(0.95, 15)
[1] 1.75305
With , and the ratio is a . Leaving 0.05 on the right is its 0.95 quantile. You get .
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Let A = «the rowing machine is taken» and B = «the instructor is on break» be two independent events, with and . Find from A and B and compare it with . Are and independent?
Solution
- P(Aᶜ ∩ Bᶜ) 0.56
- P(Aᶜ)·P(Bᶜ) 0.56
- Independent? Yes
With R
pa <- 0.3; pb <- 0.2 1 - (pa + pb - pa * pb) # P(Ac ∩ Bc) = 1 - P(A ∪ B) (1 - pa) * (1 - pb) # the product of their probabilities
[1] 0.56 [1] 0.56
By De Morgan, , and . They match, so they are independent: it is not a coincidence of these numbers, it is what you prove in the next part.
Prove that, if A and B are independent, so are and . Mark yourself with the criteria.
Solution
Marking criteria:
- Uses De Morgan: 0.75
- Writes 0.75
- Uses independence: 0.75
- Factorises: 0.75
The idea is always the same: split the event into disjoint pieces (or go to the complement with De Morgan), solve for the intersection you need and plug in independence. In the exam, write the property you use at each step: that is what earns the marks.
Let X be the fraction of the weights room capacity in use at 19:00, a continuous variable on (0, 1) with density for (and 0 elsewhere). Find K so that f is a density.
Solution
- K 0.58
With R
g <- function(x) exp(x) # the density without K K <- 1 / integrate(g, 0, 1)$value K
[1] 0.5819767
, so (0.5820 as a decimal). A density cannot be negative anywhere, and here it is not.
Find the mean and the variance of X.
Solution
- E(X) 0.58
- Var(X) 0.08
With R
f <- function(x) K * g(x) EX <- integrate(function(x) x * f(x), 0, 1)$value VX <- integrate(function(x) x^2 * f(x), 0, 1)$value - EX^2 c(EX, VX)
[1] 0.58197671 0.07932641
and , so . With two decimals: 0.58 and 0.08.
Find the distribution function of X. Check: .
Solution
- F(0.5) 0.38
With R
F <- function(x) integrate(f, 0, x)$value F(0.5)
[1] 0.3775407
For , ; if and if . At the check point, .
Using R’s curve function, plot the density f. Mark yourself with the criteria.
Solution
With R
curve(f, 0, 1, lwd = 2, ylab = "f(x)") abline(v = EX, lty = 2) # the mean, to place it
Marking criteria:
- Defines f in R with K and vectorised (it accepts a vector x) 0.5
- Calls
curve(f, 0, 1)(or withfromandto) 0.5 - Describes the shape: grows from 0.58 at to 1.58 at , like an exponential 0.5
- Places the mean (and the median of the next part) on the plot 0.5
The curve you should get: grows from 0.58 at to 1.58 at , like an exponential. If curve gives a length error, f is not vectorised: with integrate inside it would not be, which is why f is defined with the formula and not with integrals.
With R, find the median of X (for example with uniroot, or with uniroot.all from the rootSolve library).
Solution
- Median 0.62
With R
uniroot(function(x) F(x) - 0.5, c(0.001, 0.999))$root # median: F(x) = 0.5
[1] 0.6201112
The median is the x with : 0.62. It is above the mean, because the long tail is on the left.
The campus gym has two kinds of class. The duration T (in hours) depends on the kind: «Indoor cycling» handles 60% and its time is uniform between half an hour and an hour and a half; «Yoga» handles 40% and its time is gamma with shape 2 and rate 2 (mean 1). Find the probability that a class lasts more than one hour, .
Solution
- P(T > 1) 0.46
With R
t <- 1
P <- c(0.6 * punif(t, 0.5, 1.5, lower.tail = FALSE),
0.4 * pgamma(t, 2, 2, lower.tail = FALSE))
sum(P) # P(T > 1)[1] 0.4624023
By total probability: , each conditional probability coming from its model. It gives 0.46.
Given that a class lasts more than one hour, use R to find the probability that each one handled it.
Solution
- Indoor cycling 0.65
- Yoga 0.35
With R
P / sum(P) # P(source | T > 1)
[1] 0.6487856 0.3512144
Bayes: ; each term of the previous part over the total. You get 0.65, 0.35, which add up to 1.
It has 2 independent parts (2.1, 2.2…); within each one, a part often needs the one before.
Data for part 2.1.a:
cancellations <- c(2, 0, 2, 1, 2, 2, 1, 2, 1, 1,
1, 2, 1, 1, 2, 1, 0, 2, 2, 3,
4, 1, 1, 1, 4, 1, 1, 1, 0, 1,
1, 1, 4, 0, 0, 2, 4, 0, 3, 1)X is the number of members who cancel their court booking each day. It is assumed to follow a Poisson , with . The data for 40 days are in the cancellations vector of your script.
Two ways to estimate : (1) set the model mean equal to the sample mean and (2) set the model variance equal to the sample variance. With R, find by both methods and compare them.
Solution
- Method 1 1.50
- Method 2 1.28
With R
cancellations <- c(2, 0, 2, 1, 2, 2, 1, 2, 1, 1,
1, 2, 1, 1, 2, 1, 0, 2, 2, 3,
4, 1, 1, 1, 4, 1, 1, 1, 0, 1,
1, 1, 4, 0, 0, 2, 4, 0, 3, 1)
x <- cancellations; m <- mean(x); s2 <- var(x)
l1 <- m # mean: λ = sample mean
l2 <- s2 # variance: λ = sample variance
c(m, s2, l1, l2)[1] 1.500000 1.282051 1.500000 1.282051
In the Poisson the mean and the variance are both λ, so (1) gives and (2) . If the data were Poisson, the sample mean and variance would be close; here the variance is smaller than the mean.
With R and for each method, find the probability of exactly one cancellation, , and of between 2 and 4, .
Solution
- P(X = 1), meth. 1 0.33
- P(2 ≤ X ≤ 4), meth. 1 0.42
- P(X = 1), meth. 2 0.36
- P(2 ≤ X ≤ 4), meth. 2 0.36
With R
c(dpois(1, l1), ppois(4, l1) - ppois(1, l1)) # method 1: P(X = 1), P(2 <= X <= 4) c(dpois(1, l2), ppois(4, l2) - ppois(1, l2)) # method 2
[1] 0.3346952 0.4235987 [1] 0.3557276 0.3567131
is the mass at 1 (dpois) and (ppois): careful, would leave out the 2. Method 1: 0.33 and 0.42; method 2: 0.36 and 0.36.
With R, build the table of observed frequencies (classes 0, 1, 2, 3 and 4 or more) and the expected ones under each method, and draw them together with barplot. Comment. Mark yourself with the criteria.
Solution
With R
O <- table(cut(x, c(-1, 0, 1, 2, 3, Inf), labels = c("0", "1", "2", "3", "4+")))
n <- length(x)
E1 <- n * c(dpois(0:3, l1), 1 - ppois(3, l1))
E2 <- n * c(dpois(0:3, l2), 1 - ppois(3, l2))
round(rbind(O, E1, E2), 2)
barplot(rbind(O, E1, E2), beside = TRUE, legend.text = c("Observed", "Mean", "Variance"))0 1 2 3 4+ O 6.00 18.00 10.00 2.00 4.00 E1 8.93 13.39 10.04 5.02 2.63 E2 11.10 14.23 9.12 3.90 1.65
Marking criteria:
- Observed table with the five classes (the last one, «4 or more») 0.25
- Expected = n · probability of each class, with the tail in the last one 0.25
barplotwithbeside = TRUEand a legend 0.25- Comments on the classes where each model departs from the data 0.25
The expected frequencies must add up to n, like the observed ones: that is why the last class is «4 or more» (the tail), not «4». Look at the output: the two models split the frequency differently between 0 and the high classes.
To choose a model you use , with the classes of the previous part; the smaller value is preferred. Compute it for both methods and choose.
Solution
- χ² method 1 5.08
- χ² method 2 7.68
- I choose Method 1 (mean)
With R
c(sum((O - E1)^2 / E1), sum((O - E2)^2 / E2))
[1] 5.084312 7.682767
is 5.08 with method 1 and 7.68 with method 2: method 1 wins. It is a distance between what was observed and what was expected, each squared difference relative to what was expected.
Calls to reception arrive as a Poisson process of 3 per hour, so the time between one and the next is exponential with rate 3. Let T be the time until the fifth call of the afternoon. Explain which distribution T follows and give its parameters.
Solution
- Shape 5
- Rate λ 3
With R
n <- 5; la <- 3 c(n, la) # T ~ gamma(shape n, rate λ)
[1] 5 3
T is the sum of 5 independent exponentials with rate (mean 20 minutes (1/3 of an hour)). Each one’s mgf is and the sum’s is the product, , which is a gamma’s: , with mean 5/3 of an hour.
With R, find the probability that the fifth call arrives within an hour.
Solution
- P(T < 1) 0.18
With R
pgamma(1, shape = n, rate = la) # P(T < 1) 1 - ppois(n - 1, la * 1) # the same with the Poisson: P(N(t) >= n)
[1] 0.1847368 [1] 0.1847368
pgamma(1, shape = 5, rate = λ) = 0.18. It is the same as asking for at least 5 arrivals in that time (Poisson process): 1 - ppois(4, λt) gives the same number.
With R, find the 90th percentile of T and interpret it.
Solution
- 0.90 quantile 2.66
With R
qgamma(0.9, shape = n, rate = la)
[1] 2.66453
qgamma(0.9, 5, λ) = 2.66: 90% of the time T does not exceed 2.66 hours (and one in ten times it does).
The parts are linked: each one often needs the one before.
Let X be the number of failed attempts before getting three padel court bookings. Its mass function is , for , with . Find K so that is a mass function for every value of the parameter.
Solution
Check with R
th <- 0.4; x <- 0:400 # check value and many terms fx <- (1 - th)^3 * (x + 2) * (x + 1) / 2 * th^x sum(fx) # 1
[1] 1
Marking criteria:
- Checks that no term is negative 1.0
- Recognises the sum: the second derivative of the geometric series, 2.0
- Solves 1.0
- States for which parameter values it holds (all those in the statement) 1.0
Two things: no term is negative and they add up to 1. The sum is the second derivative of the geometric series, , so . In R you check it by adding many terms for a specific parameter value (the code adds up to 1 with ).
Find the moment generating function . Check: with , give and .
Solution
- φ(0.2) 1.61
- P(X = 1) 0.26
With R
t <- 0.2 c(sum(exp(t * x) * fx), ((1 - th) / (1 - th * exp(t)))^3, fx[x == 1]) # φ(0.2) with sums and with the formula; P(X = 1)
[1] 1.614628 1.614628 0.259200
Put inside the sum and group it with the power of the parameter: you get the same sum as in the previous part with another argument, , for . With : and .
Find . Check: its value with .
Solution
- E(X) 2
With R
c(sum(x * fx), 3 * th / (1 - th)) # E(X) with sums and with the formula
[1] 2 2
Differentiating the mgf at 0 (or summing directly): . With , 2.00. The code checks it with a long sum.
It adds up separately: up to 2.5 more points, on top of the 50.
Let . Using only its moment generating function, find .
Solution
- E(2ˣ) 7.39
With R
exp(2 * (2 - 1)) # with the mgf set.seed(1) mean(2^rpois(1e6, 2)) # simulating: almost the same
[1] 7.389056 [1] 7.361848
, so with : . It is 7.39.
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Let be the amount (in euros) of each of the 50 orders in an afternoon at the cafeteria, independent with common density , . Let ; you would want . Using R and applying, if possible, the central limit theorem, find the requested probability approximately. Also give the mean and the variance of each .
Solution
- E(Xᵢ) 2
- Can the CLT be applied? No
With R
f <- function(x) 2 / x^3 integrate(function(x) x * f(x), 1, Inf)$value # E(X) sapply(c(1e2, 1e4, 1e6), function(M) integrate(function(x) x^2 * f(x), 1, M)$value) # E(X^2) up to M: it keeps growing
[1] 2 [1] 9.21034 18.42068 27.63102
, but : the variance is not finite and the CLT (which needs a finite variance) cannot be applied. The output shows it: the integral up to M grows like forever. The sum is dominated by a few huge values and does not look like a normal.
The fraction X of the cup that gets filled with coffee and the fraction Y of milk the customer asks for are uniform on (0, 1) and independent. Find the distribution of . Mark yourself with the criteria.
Solution
Marking criteria:
- Introduces an auxiliary variable (for example ) and writes the inverse 1.0
- Computes the Jacobian and its absolute value 1.0
- Writes the joint density of (U, V) and its support (drawn) 1.5
- Integrates out V piece by piece and reaches : 2.0
- Checks that integrates to 1 (or draws its shape) 0.5
With : , and where . Integrating from to 1: .
Check of the above: give and .
Solution
- f_U(0.5) 0.69
- P(U ≤ 0.25) 0.60
With R
fU <- function(u) integrate(function(v) dunif(u / v) * dunif(v) / v, u, 1)$value c(fU(0.5), integrate(Vectorize(fU), 0, 0.25)$value) # f_U(0.5) and P(U ≤ 0.25) set.seed(5) mean(runif(1e5) * runif(1e5) <= 0.25) # simulating
[1] 0.6931472 0.5965736 [1] 0.59883
With the density of the previous part, and . The code integrates the joint density numerically at each point and the simulation gives almost the same.
The error (in °C) of the coffee machine thermometer is : the mean 0 is known and is not. Let be a simple random sample. Prove that the maximum likelihood estimator of is unbiased, consistent and efficient. Mark yourself with the criteria.
Solution
Marking criteria:
- Writes the log-likelihood, differentiates, sets it to 0 and reaches the MLE: 2.0
- Unbiased: computes of the estimator and gets the parameter 1.5
- Consistent: unbiased and with variance 1.5
- Computes the Fisher information and the bound 1.5
- Concludes it is efficient: its variance attains the bound 0.5
gives ; , so and ; and the bound is .
Check: with and , give the variance of the MLE and the Cramér-Rao bound (with four decimals).
Solution
- Var(MLE) 1
- CR bound 1
- Efficient? Yes
With R
s2 <- 4; n <- 32 c(2 * s2^2 / n, 1 / (n / (2 * s2^2))) # Var of the MLE and Cramér-Rao bound set.seed(3); e <- replicate(10000, mean(rnorm(n, 0, sqrt(s2))^2)) c(mean(e), var(e)) # simulating: mean and variance of the MLE
[1] 1 1 [1] 4.007916 1.001578
and the bound : they match, so it is efficient. Simulating 10,000 samples gives an estimator mean almost equal to the parameter (unbiased) and a variance almost equal to the bound.
The parts are linked: each one often needs the one before.
Data for part 2.a:
before <- c(68, 67.8, 71.5, 72.7, 68.8, 72.2, 69.1, 74.4, 68.8, 70.7,
70.8, 71.2, 74.1, 70.6, 66, 74.5, 72.9, 67.7, 72.4, 67.9,
81.2, 77.2, 70.4, 68.9, 65.9)Data for part 2.b:
after <- c(65.2, 66.1, 67.5, 67.6, 67.2, 69.7, 66.5, 71.7, 66.1, 68.1,
68.1, 70.5, 71.5, 71.4, 64.1, 70.4, 70.4, 65.6, 68.3, 61.6,
78.5, 74.6, 68.1, 64.3, 64)The temperature (in °C) of 25 freshly served coffees was measured. The data are already in the before vector of your script.
Assuming normal data with and unknown, give a maximum likelihood estimate of each parameter and a 95% confidence interval for each one. Use R.
Solution
- μ̂ 71.03
- μ: lower 69.58
- μ: upper 72.48
- σ̂² 11.81
- σ²: lower 7.50
- σ²: upper 23.80
With R
before <- c(68, 67.8, 71.5, 72.7, 68.8, 72.2, 69.1, 74.4, 68.8, 70.7,
70.8, 71.2, 74.1, 70.6, 66, 74.5, 72.9, 67.7, 72.4, 67.9,
81.2, 77.2, 70.4, 68.9, 65.9)
after <- c(65.2, 66.1, 67.5, 67.6, 67.2, 69.7, 66.5, 71.7, 66.1, 68.1,
68.1, 70.5, 71.5, 71.4, 64.1, 70.4, 70.4, 65.6, 68.3, 61.6,
78.5, 74.6, 68.1, 64.3, 64)
x <- before; n <- length(x)
c(mean(x), t.test(x, conf.level = 0.95)$conf.int) # μ: estimate and interval
s2 <- var(x); a <- 0.05
c((n - 1) * s2 / n, (n - 1) * s2 / qchisq(1 - a / 2, n - 1), (n - 1) * s2 / qchisq(a / 2, n - 1)) # σ²[1] 71.0280 69.5804 72.4756 [1] 11.806816 7.498471 23.801857
; its interval, with the t: . The MLE of divides by n: ; its interval, with the chi-squared: , which is not symmetric.
After calibrating the machine, the measurement is repeated with the same 25 orders (same kind of coffee and cup). The data are in after, in the same order. With R, give a 95% interval for the variance ratio . Can they be assumed equal?
Solution
- Lower 0.41
- Upper 2.09
- Equal variances? Yes
With R
c(var.test(before, after, conf.level = 0.95)$conf.int) # σ²(before) / σ²(after)
[1] 0.4064083 2.0928478
With Snedecor’s F, the interval is . It contains 1, so there is no reason to say the variances are different.
Assume two paired normal samples and , and let with mean . Prove that follows a Student’s t with degrees of freedom. Mark yourself with the criteria.
Solution
Marking criteria:
- The are independent normals (linear combination of normals; each pair is subtracted inside) 0.75
- 0.75
- , independent of (Fisher) 0.75
- Divides the normal by : cancels and a remains 0.75
The key to paired data is that there are not two samples: there is one, the differences. From there it is the one-sample t, which is why the degrees of freedom are and not .
With the above, give a maximum likelihood estimate of the mean difference and a 90% interval. Interpret it. Use R.
Solution
- d̄ -2.74
- Lower -3.23
- Upper -2.26
- Is there a change? Yes
With R
d <- after - before c(mean(d), t.test(after, before, paired = TRUE, conf.level = 0.9)$conf.int)
[1] -2.744000 -3.229328 -2.258672
They are the same units measured twice, so you work with the differences: and the paired interval is . It does not contain 0: there is a real change, downwards.
The parts are linked: each one often needs the one before.
Data for part 3.e:
waits <- c(9.5, 2.7, 8.8, 11.9, 9.2, 2.2, 0.9, 4.6, 8.3, 0.9)
The time (in minutes) a customer waits to be served, uniform between 0 and a maximum . They are modelled with a population with density , with unknown. Let be a simple random sample. Prove that the maximum likelihood estimator is .
Solution
Marking criteria:
- Writes the likelihood 0.75
- Sees it decreases in θ from and is 0 below it 1.5
- Concludes (no derivative: the maximum is at the edge) 0.75
For the uniform the likelihood is if and 0 otherwise: it decreases, so the maximum is at the edge, . Differentiating and setting to 0 does not work here.
Find the distribution of the maximum .
Solution
Marking criteria:
- 1.0
- Uses independence: product of the n 1.0
- Reaches and its density 1.0
Result: .
Find the distribution of and justify that it is a pivot.
Solution
Check with R
n <- 10; set.seed(4) u <- replicate(10000, max(runif(n, 0, 3)) / 3) c(mean(u), n / (n + 1)) # the mean of a beta(n, 1)
[1] 0.9076060 0.9090909
Marking criteria:
- Change of variable (or mgf) from the previous part 1.0
- Reaches: 1.5
- States it does not depend on the parameter: it is a pivot 0.5
: its distribution does not depend on the parameter, so it works as a pivot. The simulation checks it with an arbitrary parameter value.
With that pivot, build a confidence interval of level for .
Solution
Marking criteria:
- Sets with the pivot’s quantiles 1.0
- Solves for the parameter inside the probability 1.0
- Reaches: 1.0
Interval: .
10 waits were timed. They are in the waits vector of your script. With R, give the estimate of and the 95% interval.
Solution
- Estimate 11.90
- Lower 11.90
- Upper 16.06
With R
waits <- c(9.5, 2.7, 8.8, 11.9, 9.2, 2.2, 0.9, 4.6, 8.3, 0.9) x <- waits; n <- length(x); a <- 0.05 M <- max(x) c(M, M, M / a^(1 / n)) # estimate, lower and upper limit
[1] 11.90000 11.90000 16.05647
With : estimate 11.90 and interval .
It adds up separately: up to 5 more points, on top of the 50.
For the last 30 customers of two shifts, it is recorded whether they ordered food (1) or not (0):
First: c(1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0)
Second: c(1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0)
With R, give a maximum likelihood estimate of each proportion and of their difference.
Solution
- p̂₁ 0.50
- p̂₂ 0.33
- p̂₁ − p̂₂ 0.17
With R
x <- c(1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0) y <- c(1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0) p1 <- mean(x); p2 <- mean(y) c(p1, p2, p1 - p2)
[1] 0.5000000 0.3333333 0.1666667
The MLE of a proportion is the sample proportion: 0.50 and 0.33; the difference, 0.17.
Give a 95% asymptotic confidence interval for . Are they different?
Solution
- Lower -0.08
- Upper 0.41
- Different? No
With R
m <- length(x); n <- length(y); z <- qnorm(0.975) (p1 - p2) + c(-1, 1) * z * sqrt(p1 * (1 - p1) / m + p2 * (1 - p2) / n)
[1] -0.07923455 0.41256788
. It contains 0: you cannot say they are different.
Let be the sample variance of 8 data and that of 12 data , independent. With R, find such that .
Solution
- a 1.34
With R
# (S1² / 4) / (S2² / 9) ~ F(7, 11); P(S1² / S2² <= a) = 0.95 (4 / 9) * qf(0.95, 7, 11)
[1] 1.338813
, so is the same as : . You get .
It has 3 independent parts (1.1, 1.2…); within each one, a part often needs the one before.
Data for part 1.3.a:
snails <- c(1, 5, 1, 2, 1, 0, 4, 2, 2, 0,
1, 1, 4, 0, 1, 2, 0, 5, 0, 2,
4, 2, 1, 0, 5, 3, 0, 3, 6, 4,
1, 1, 4, 4, 2, 4, 2, 2, 2, 2)Let A = «the tomato plants have aphids» and B = «the watering hose breaks» be two independent events, with and . Find from A and B and compare it with . Are and independent?
Solution
- P(Aᶜ ∩ Bᶜ) 0.52
- P(Aᶜ)·P(Bᶜ) 0.52
- Independent? Yes
With R
pa <- 0.35; pb <- 0.2 1 - (pa + pb - pa * pb) # P(Ac ∩ Bc) = 1 - P(A ∪ B) (1 - pa) * (1 - pb) # the product of their probabilities
[1] 0.52 [1] 0.52
By De Morgan, , and . They match, so they are independent: it is not a coincidence of these numbers, it is what you prove in the next part.
Prove that, if A and B are independent, so are and . Mark yourself with the criteria.
Solution
Marking criteria:
- Uses De Morgan: 0.75
- Writes 0.75
- Uses independence: 0.75
- Factorises: 0.75
The idea is always the same: split the event into disjoint pieces (or go to the complement with De Morgan), solve for the intersection you need and plug in independence. In the exam, write the property you use at each step: that is what earns the marks.
Let X be the fraction of the garden water tank left at the end of the day, a continuous variable on (0, 1) with density for (and 0 elsewhere). Find K so that f is a density.
Solution
- K 1.44
With R
g <- function(x) 1 / (1 + x) # the density without K K <- 1 / integrate(g, 0, 1)$value K
[1] 1.442695
, so (1.4427 as a decimal). A density cannot be negative anywhere, and here it is not.
Find the mean and the variance of X.
Solution
- E(X) 0.44
- Var(X) 0.08
With R
f <- function(x) K * g(x) EX <- integrate(function(x) x * f(x), 0, 1)$value VX <- integrate(function(x) x^2 * f(x), 0, 1)$value - EX^2 c(EX, VX)
[1] 0.44269504 0.08267358
and , so . With two decimals: 0.44 and 0.08.
Find the distribution function of X. Check: .
Solution
- F(0.5) 0.58
With R
F <- function(x) integrate(f, 0, x)$value F(0.5)
[1] 0.5849625
For , ; if and if . At the check point, .
Using R’s curve function, plot the density f. Mark yourself with the criteria.
Solution
With R
curve(f, 0, 1, lwd = 2, ylab = "f(x)") abline(v = EX, lty = 2) # the mean, to place it
Marking criteria:
- Defines f in R with K and vectorised (it accepts a vector x) 0.5
- Calls
curve(f, 0, 1)(or withfromandto) 0.5 - Describes the shape: goes down gently from 1.44 at to 0.72 at 0.5
- Places the mean (and the median of the next part) on the plot 0.5
The curve you should get: goes down gently from 1.44 at to 0.72 at . If curve gives a length error, f is not vectorised: with integrate inside it would not be, which is why f is defined with the formula and not with integrals.
With R, find the median of X (for example with uniroot, or with uniroot.all from the rootSolve library).
Solution
- Median 0.41
With R
uniroot(function(x) F(x) - 0.5, c(0.001, 0.999))$root # median: F(x) = 0.5
[1] 0.4142335
The median is the x with : 0.41. It is below the mean, because the long tail is on the right.
X is the number of snails that appear each morning in a bed of the urban garden. It is assumed to follow a Poisson , with . The data for 40 days are in the snails vector of your script.
Two ways to estimate : (1) set the model mean equal to the sample mean and (2) set the model variance equal to the sample variance. With R, find by both methods and compare them.
Solution
- Method 1 2.15
- Method 2 2.80
With R
snails <- c(1, 5, 1, 2, 1, 0, 4, 2, 2, 0,
1, 1, 4, 0, 1, 2, 0, 5, 0, 2,
4, 2, 1, 0, 5, 3, 0, 3, 6, 4,
1, 1, 4, 4, 2, 4, 2, 2, 2, 2)
x <- snails; m <- mean(x); s2 <- var(x)
l1 <- m # mean: λ = sample mean
l2 <- s2 # variance: λ = sample variance
c(m, s2, l1, l2)[1] 2.150000 2.797436 2.150000 2.797436
In the Poisson the mean and the variance are both λ, so (1) gives and (2) . If the data were Poisson, the sample mean and variance would be close; here the variance is larger than the mean.
With R and for each method, find the probability of exactly one snail, , and of between 2 and 4, .
Solution
- P(X = 1), meth. 1 0.25
- P(2 ≤ X ≤ 4), meth. 1 0.57
- P(X = 1), meth. 2 0.17
- P(2 ≤ X ≤ 4), meth. 2 0.62
With R
c(dpois(1, l1), ppois(4, l1) - ppois(1, l1)) # method 1: P(X = 1), P(2 <= X <= 4) c(dpois(1, l2), ppois(4, l2) - ppois(1, l2)) # method 2
[1] 0.2504409 0.5658752 [1] 0.170549 0.616560
is the mass at 1 (dpois) and (ppois): careful, would leave out the 2. Method 1: 0.25 and 0.57; method 2: 0.17 and 0.62.
With R, build the table of observed frequencies (classes 0, 1, 2, 3 and 4 or more) and the expected ones under each method, and draw them together with barplot. Comment. Mark yourself with the criteria.
Solution
With R
O <- table(cut(x, c(-1, 0, 1, 2, 3, Inf), labels = c("0", "1", "2", "3", "4+")))
n <- length(x)
E1 <- n * c(dpois(0:3, l1), 1 - ppois(3, l1))
E2 <- n * c(dpois(0:3, l2), 1 - ppois(3, l2))
round(rbind(O, E1, E2), 2)
barplot(rbind(O, E1, E2), beside = TRUE, legend.text = c("Observed", "Mean", "Variance"))0 1 2 3 4+ O 7.00 9.00 11.00 2.00 11.00 E1 4.66 10.02 10.77 7.72 6.84 E2 2.44 6.82 9.54 8.90 12.30
Marking criteria:
- Observed table with the five classes (the last one, «4 or more») 0.5
- Expected = n · probability of each class, with the tail in the last one 0.5
barplotwithbeside = TRUEand a legend 0.5- Comments on the classes where each model departs from the data 0.5
The expected frequencies must add up to n, like the observed ones: that is why the last class is «4 or more» (the tail), not «4». Look at the output: the two models split the frequency differently between 0 and the high classes.
To choose a model you use , with the classes of the previous part; the smaller value is preferred. Compute it for both methods and choose.
Solution
- χ² method 1 8.06
- χ² method 2 14.93
- I choose Method 1 (mean)
With R
c(sum((O - E1)^2 / E1), sum((O - E2)^2 / E2))
[1] 8.056155 14.934512
is 8.06 with method 1 and 14.93 with method 2: method 1 wins. It is a distance between what was observed and what was expected, each squared difference relative to what was expected.
It has 2 independent parts (2.1, 2.2…); within each one, a part often needs the one before.
Out of 200 seeds, each germinates with probability 0.3, independently. Let N be the number that germinate (binomial). Using Chebyshev’s inequality, find a lower bound for .
Solution
- Lower bound 0.58
With R
n <- 200; p <- 0.3; k <- 10 1 - n * p * (1 - p) / k^2 # Chebyshev bound
[1] 0.58
and . The interval is , so .
Using R, compare with the exact value.
Solution
- Exact 0.90
With R
pbinom(70, n, p) - pbinom(49, n, p) # exact
[1] 0.8952008
The exact value is 0.90, much more than the bound 0.58: Chebyshev holds for any distribution, which is why it falls short.
Let X be the number of the four pots on a balcony that flower this month. Its mass function is , for , with . Find K so that is a mass function for every value of the parameter.
Solution
Check with R
th <- 0.5; x <- 0:4 # check value and many terms fx <- choose(4, x) * th^x / (1 + th)^4 sum(fx) # 1
[1] 1
Marking criteria:
- Checks that no term is negative 1.0
- Recognises the sum: Newton’s binomial, 2.0
- Solves 1.0
- States for which parameter values it holds (all those in the statement) 1.0
Two things: no term is negative and they add up to 1. The sum is Newton’s binomial, , so . In R you check it by adding many terms for a specific parameter value (the code adds up to 1 with ).
Find the moment generating function . Check: with , give and .
Solution
- φ(0.3) 1.55
- P(X = 1) 0.40
With R
t <- 0.3 c(sum(exp(t * x) * fx), ((1 + th * exp(t)) / (1 + th))^4, fx[x == 1]) # φ(0.3) with sums and with the formula; P(X = 1)
[1] 1.5546083 1.5546083 0.3950617
Put inside the sum and group it with the power of the parameter: you get the same sum as in the previous part with another argument, , for every t. With : and .
Find . Check: its value with .
Solution
- E(X) 1.33
With R
c(sum(x * fx), 4 * th / (1 + th)) # E(X) with sums and with the formula
[1] 1.333333 1.333333
Differentiating the mgf at 0 (or summing directly): . With , 1.33. The code checks it with a long sum.
It has 3 independent parts (3.1, 3.2…); within each one, a part often needs the one before.
Data for part 3.3.a:
before <- c(7.05, 7.07, 6.66, 6.82, 6.83, 6.64, 6.84, 6.75, 7.02, 6.66,
7.25, 6.89, 6.92, 7.03, 6.85, 7.1, 7.03, 6.74, 6.85, 6.85,
6.2, 7.06, 7.03, 6.2, 6.6)Data for part 3.3.b:
after <- c(6.78, 7.45, 6.25, 6.53, 6.24, 6.24, 6.48, 6.72, 6.82, 6.9,
7.08, 6.97, 6.89, 6.58, 6.45, 7.1, 6.77, 6.7, 6.41, 6.42,
6.09, 7.19, 7.3, 6.25, 6.38)The height X of a plant and that of its stake Y (in metres) are uniform on (0, 1) and independent. Find the distribution of . Mark yourself with the criteria.
Solution
Marking criteria:
- Introduces an auxiliary variable (for example ) and writes the inverse 1.0
- Computes the Jacobian and its absolute value 1.0
- Writes the joint density of (U, V) and its support (drawn) 1.5
- Integrates out V piece by piece and reaches : 2.0
- Checks that integrates to 1 (or draws its shape) 0.5
With : , and where and . If , runs from 0 to 1 and you get 1/2; if , from 0 to and you get .
Check of the above: give and .
Solution
- f_U(2) 0.13
- P(U > 2) 0.25
With R
fU <- function(u) integrate(function(v) dunif(u * v) * dunif(v) * v, 0, min(1, 1 / u))$value c(fU(2), 1 - integrate(Vectorize(fU), 0, 2)$value) # f_U(2) and P(U > 2) set.seed(5) mean(runif(1e5) / runif(1e5) > 2) # simulating
[1] 0.125 0.250 [1] 0.25076
With the density of the previous part, and . The code integrates the joint density numerically at each point and the simulation gives almost the same.
The weight (in grams) of a tomato is , with the variance known. Let be a simple random sample. Prove that the maximum likelihood estimator of is unbiased, consistent and efficient. Mark yourself with the criteria.
Solution
Marking criteria:
- Writes the log-likelihood, differentiates, sets it to 0 and reaches the MLE: 2.0
- Unbiased: computes of the estimator and gets the parameter 1.5
- Consistent: unbiased and with variance 1.5
- Computes the Fisher information and the bound 1.5
- Concludes it is efficient: its variance attains the bound 0.5
gives ; unbiased, , and the bound is .
Check: with and , give the variance of the MLE and the Cramér-Rao bound (with four decimals).
Solution
- Var(MLE) 0.3600
- CR bound 0.3600
- Efficient? Yes
With R
s2 <- 9; n <- 25 c(s2 / n, 1 / (n / s2)) # Var of the MLE and Cramér-Rao bound set.seed(3); e <- replicate(10000, mean(rnorm(n, 10, sqrt(s2)))) c(mean(e), var(e)) # simulating: mean and variance of the MLE
[1] 0.36 0.36 [1] 9.9936234 0.3612149
and the bound : they match, so it is efficient. Simulating 10,000 samples gives an estimator mean almost equal to the parameter (unbiased) and a variance almost equal to the bound.
The pH of the irrigation water was measured in 25 pots. The data are already in the before vector of your script.
Assuming normal data with and unknown, give a maximum likelihood estimate of each parameter and a 95% confidence interval for each one. Use R.
Solution
- μ̂ 6.84
- μ: lower 6.73
- μ: upper 6.94
- σ̂² 0.06
- σ²: lower 0.04
- σ²: upper 0.12
With R
before <- c(7.05, 7.07, 6.66, 6.82, 6.83, 6.64, 6.84, 6.75, 7.02, 6.66,
7.25, 6.89, 6.92, 7.03, 6.85, 7.1, 7.03, 6.74, 6.85, 6.85,
6.2, 7.06, 7.03, 6.2, 6.6)
after <- c(6.78, 7.45, 6.25, 6.53, 6.24, 6.24, 6.48, 6.72, 6.82, 6.9,
7.08, 6.97, 6.89, 6.58, 6.45, 7.1, 6.77, 6.7, 6.41, 6.42,
6.09, 7.19, 7.3, 6.25, 6.38)
x <- before; n <- length(x)
c(mean(x), t.test(x, conf.level = 0.95)$conf.int) # μ: estimate and interval
s2 <- var(x); a <- 0.05
c((n - 1) * s2 / n, (n - 1) * s2 / qchisq(1 - a / 2, n - 1), (n - 1) * s2 / qchisq(a / 2, n - 1)) # σ²[1] 6.837600 6.733342 6.941858 [1] 0.06124224 0.03889475 0.12346081
; its interval, with the t: . The MLE of divides by n: ; its interval, with the chi-squared: , which is not symmetric.
After adding a liquid fertiliser, the pH of the same 25 pots is measured again. The data are in after, in the same order. With R, give a 95% interval for the variance ratio . Can they be assumed equal?
Solution
- Lower 0.21
- Upper 1.07
- Equal variances? Yes
With R
c(var.test(before, after, conf.level = 0.95)$conf.int) # σ²(before) / σ²(after)
[1] 0.2075266 1.0686829
With Snedecor’s F, the interval is . It contains 1, so there is no reason to say the variances are different.
Assume two paired normal samples and , and let with mean . Prove that follows a Student’s t with degrees of freedom. Mark yourself with the criteria.
Solution
Marking criteria:
- The are independent normals (linear combination of normals; each pair is subtracted inside) 0.75
- 0.75
- , independent of (Fisher) 0.75
- Divides the normal by : cancels and a remains 0.75
The key to paired data is that there are not two samples: there is one, the differences. From there it is the one-sample t, which is why the degrees of freedom are and not .
With the above, give a maximum likelihood estimate of the mean difference and a 95% interval. Interpret it. Use R.
Solution
- d̄ -0.16
- Lower -0.26
- Upper -0.05
- Is there a change? Yes
With R
d <- after - before c(mean(d), t.test(after, before, paired = TRUE, conf.level = 0.95)$conf.int)
[1] -0.15800000 -0.26393786 -0.05206214
They are the same units measured twice, so you work with the differences: and the paired interval is . It does not contain 0: there is a real change, downwards.
The parts are linked: each one often needs the one before.
Data for part 4.e:
waterings <- c(2.4, 12.2, 0.6, 0.8, 0.2, 4.6, 1.3, 1.7, 4.2, 9.3)
The days the tank lasts without refilling, exponential with mean (in days). They are modelled with a population with density , with unknown. Let be a simple random sample. Prove that the maximum likelihood estimator is .
Solution
Marking criteria:
- Writes the log-likelihood 1.25
- Differentiates with respect to the parameter and sets it to 0 1.25
- Solves for the estimator 1.25
- Checks it is a maximum (negative second derivative) 1.25
The logarithm turns the product into a sum; differentiating and setting to 0 gives , and the second derivative is negative.
Find the distribution of .
Solution
Marking criteria:
- Sees each term is exponential 1.6667
- Uses the mgf: the sum’s is the product (independence) 1.6667
- Recognises the mgf of a gamma with shape n 1.6666
Result: .
Find the distribution of .
Solution
Check with R
n <- 10; set.seed(4) u <- replicate(10000, 2 * sum(rexp(n, 1 / 1.5)) / 1.5) # U with any parameter value c(mean(u), var(u), 2 * n, 4 * n) # mean and variance: those of a chi-squared with 2n df
[1] 20.10030 40.32068 20.00000 40.00000
Marking criteria:
- Change of variable (or mgf) from the previous part 1.6667
- Reaches: 2.5
- States it does not depend on the parameter: it is a pivot 0.8333
: its distribution does not depend on the parameter, so it works as a pivot. The simulation checks it with an arbitrary parameter value.
With that pivot, build a confidence interval of level for .
Solution
Marking criteria:
- Sets with the pivot’s quantiles 1.6667
- Solves for the parameter inside the probability 1.6667
- Reaches: 1.6666
Interval: .
10 periods between refills were recorded. They are in the waterings vector of your script. With R, give the estimate of and the 95% interval.
Solution
- Estimate 3.73
- Lower 2.18
- Upper 7.78
With R
waterings <- c(2.4, 12.2, 0.6, 0.8, 0.2, 4.6, 1.3, 1.7, 4.2, 9.3) x <- waterings; n <- length(x); a <- 0.05 T <- sum(x) c(mean(x), 2 * T / qchisq(1 - a / 2, 2 * n), 2 * T / qchisq(a / 2, 2 * n)) # estimate, lower and upper limit
[1] 3.730000 2.183227 7.778306
With : estimate 3.73 and interval .
It adds up separately: up to 10 more points, on top of the 100.
Let . Using only its moment generating function, find .
Solution
- E(3ˣ) 18.90
With R
(0.6 + 0.4 * 3)^5 # with the mgf set.seed(1) mean(3^rbinom(1e6, 5, 0.4)) # simulating: almost the same
[1] 18.89568 [1] 18.84428
, so . It is 18.90.
Let be the sample variance of 10 independent data . With R, find such that .
Solution
- a 3.76
With R
# 9 S² / 2 ~ chi2(9); P(S² <= a) = 0.95 => a = 2 · 0.95 quantile / 9 2 * qchisq(0.95, 9) / 9
[1] 3.759773
, so is the same as : . You get .
If you choose On paper, press «Download the exam (PDF)»: each format and each version has its own, with the cover, the empty score table and the boxes for each part, without solutions. R stays beside you for whatever needs it, like in the exam room.
The D versions rotate topics. In part 1, the density is exponential, the mixture has two models and asks about the right tail, the fit is a Poisson’s, the sum of exponentials is also counted with a Poisson process and the mass is a negative binomial. In part 2, the CLT cannot be applied (the variance is infinite), the transformation is a product, the estimator is the variance of a normal with known mean and the pivot is the maximum of a uniform. In the whole subject, Chebyshev is applied to a binomial, the transformation is a quotient and the pivot is the mean of an exponential.
What the ME1 final is like
The final (and the resit, with the same format) is held in the exam room, with your laptop and RStudio, inside the exam’s secure browser. It has two parts, one per continuous assessment, and you only sit the ones you are missing:
| Format | When | Duration | Exercises | Bonus |
|---|---|---|---|---|
| Part 1 | You are missing the EC1 part (topics 1-4) | 3 hours | 1 (25 points), 2 (10) and 3 (15): 50 | 2.5 |
| Part 2 | You are missing the EC2 part (topics 5-11) | 3 hours | 1 (25 points), 2 (10) and 3 (15): 50 | 5 |
| Whole subject | You are missing both | 4 hours | 1 (25), 2 (20), 3 (30) and 4 (25): 100 | 10 |
The 3 hours of the parts are what the 2025-26 finals gave as the maximum duration (the course guide says 2 hours for a single part): the mock uses 3 so you train with the longer time, and if your sitting gives 2, the split in «How to split the time» tells you what to cut.
The exercises are of the same kind as EC1’s and EC2’s, but longer: each one joins two or three independent parts (1.1, 1.2, 1.3…), and within each part the questions are linked. There are calculations and proofs by hand and parts with R, and all results are given with two decimals.
| Format | Exercise | What is asked | Topics |
|---|---|---|---|
| Part 1 | 1 | Two independent events (a calculation and the proof with the complements), a density with a constant K on (0, 1) (K, mean, variance, F, curve and the median with R) and a mixture of three models with total probability and Bayes | 2 and 4 |
| Part 1 | 2 | A discrete model fitted by the mean and by the variance with data, its probabilities, barplot of observed against expected and a chi-squared to choose; and a sum of exponentials that is a gamma | 3 and 4 |
| Part 1 | 3 | A mass function with a constant and a parameter: K, the mgf and the mean | 3 |
| Part 2 | 1 | A CLT, the distribution of a transformation of two variables with the change of variables, and that an MLE is unbiased, consistent and efficient | 6, 7 and 10 |
| Part 2 | 2 | Intervals with R for a normal (mean and variance), the variance ratio, the proof of the paired t and the paired mean difference | 8 and 11 |
| Part 2 | 3 | A pivot: the MLE, the distribution of a sum, the change to a chi-squared, the interval and the interval with data | 9 and 11 |
| Whole | 1 and 2 | The events, the density with K, the fit of the discrete model, Chebyshev against the exact value and the mass with K | 2, 3, 4 and 7 |
| Whole | 3 and 4 | The transformation of two variables, the MLE properties, the intervals and the pivot, with 5 points per part | 6 and 8-11 |
The bonuses add up separately: an mgf to find in part 1; two proportions and a quantile in part 2; and the mgf and a quantile in the whole subject.
What do you sit?
It depends on what you got in EC1 and EC2. With the rules of the 2026/27 guide, an EC with 25 or more is kept for the final and the resit; with over 20 in both and 50 between them you already pass by coursework.
If you only have one part left, your subject mark is (the EC you keep + the part) / 10. If you sit the whole subject, it is the score divided by 10. In both cases the extra from the virtual campus quizzes and the bonuses is added, never above 10, and the ME1 calculator works it out with your real marks.
What you can bring: three sheets and your .R
You go into the final with two things of your own:
- A handwritten cheat sheet, three sheets on both sides (one in EC1 and two in EC2). Results are allowed, but not proofs. The cheat sheet at the end of this article joins both parts.
- A single
.Rfile that you upload to the campus before a deadline, with your code from the classes and the labs. 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 for each exercise: without it, that exercise is not marked. In the mock, the script on the right plays that role: when you hand in you can download it.
Going to the final with the cheat sheet for the EC you failed and forgetting the other one. If you sit the whole subject, the three sheets must cover all eleven topics: half the mark comes from the part you thought you had passed.
How it is marked
Each part is a cell of the score table (1.1.a, 1.1.b, 1.2.a… and those of 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 there are several boxes, each is worth its share. The paper parts with a general formula (the mgf of a mass, the density of a transformation) ask for a check value: the box is filled with a specific value of the parameter given in the statement. The variances of the estimators go with four decimals, because with two they would come out as 0.00.
- Proofs. When you hand in you get the criteria with their points (for example, «introduces an auxiliary variable», «computes the Jacobian», «integrates piece by piece») and you tick the ones you did. It is how the lecturer marks: by steps.
Parts that need working in the exam have the «I worked it out on paper» box: unticked they score 0 even if the result is right, because in the real exam a number with no working does not score. The ones done only with R do not have it.
The mark is out of 50 in the parts (with 25 you pass that part) and out of 100 in the whole subject (with 50 you pass), with the bonus on top. In the whole subject, exercises 1 and 2 are the EC1 part and 3 and 4 the EC2 part: the breakdown tells you which of the two drags your mark down.
The four versions
| Version | Part 1 | Part 2 | Whole subject |
|---|---|---|---|
| A | The home delivery: three vans, geometric complaints, the express checkout and the app offers | The library: the scanner (CLT), two friends arriving, late returns (Poisson), a sudoku workshop and the loans (exponential) | A rural hotel: the density , claims, arrivals (Chebyshev), towels, breakfast, water and the night calls |
| B | The FabLab: three 3D printers, failed parts, the laser cutter and screws in pairs | The solar panels: full sun (CLT), two uniform start-ups, cleaning (Bernoulli), output before and after and the log files (Pareto) | An online T-shirt shop: returns (Poisson), bulk orders, printing and packing (sum of uniforms), purchases and large orders (Pareto) |
| C | The student halls: three lifts, parcels at the front desk (Poisson), the porter and cooking on Saturday | The airport: electric carts (CLT), delays of two flights (Laplace), the security check, the suitcases and boarding | The athletics club: false starts, members at the track, lost bibs, the athlete and the coach, pre-season and the reaction to the gun |
| D | The gym: two kinds of class, cancellations, calls to reception and the padel court | The cafeteria: orders with no finite variance, the coffee with milk (a product), the thermometer, the calibrated machine and waiting at the counter (uniform) | The urban garden: snails (Poisson), seeds (Chebyshev with a binomial), pots, the plant and its stake (a quotient), the pH and the tank |
How the mock exam works
Choose format, 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.
R is on your right. It is the site’s R environment (R in the browser, with RStudio’s panes): the final-p1-A.R script (or the one for your format and version) already has each exercise’s data in its vectors and a gap under each one. Ctrl + Enter runs the line and Ctrl + Shift + Enter, everything. The first time R takes a few seconds to load. The middle divider can be dragged, and on a phone you switch between «Exam» and «R» with the tabs at the top.
For the density of a transformation you do not need to guess the pieces with R: fU <- function(u) integrate(function(v) fX(u + v) * fY(v), a, b)$value integrates the joint density at each point, and Vectorize(fU) lets you pass it to integrate or curve. It is the check the solutions use.
Handing in. You see the mark, the score table, the zone you fall into, the proof criteria to tick and, for each part, the worked solution with the R code and its real output, and a «Revise this topic» link. With «Download my .R script» you keep what you wrote. Nothing is stored on any server.
How to split the time
In the parts it works out at about 3.6 minutes per point; in the whole subject, 2.4. A split that works, leaving a while at the end to check and save the script:
| Block | Part 1 (3 h) | Part 2 (3 h) | Whole subject (4 h) |
|---|---|---|---|
| Exercise 1 | 75 min: quick events, the density with R and the mixture | 80 min: the CLT is quick; the transformation, with a drawing of the support | 50 min |
| Exercise 2 | 40 min: the fit is almost all R | 35 min: all with R except the paired t | 40 min |
| Exercise 3 | 40 min: the series is the hard part; the mgf and the mean come from it | 45 min: the four pivot proofs and the interval with data | 70 min |
| Exercise 4 | — | — | 50 min |
| Bonus | 10 min | 10 min | 15 min |
| Checking and uploading the .R | 15 min | 10 min | 15 min |
If your part is 2 hours long, cut mostly from exercise 1 (long but very procedural) and leave the bonus for the end. If a part gets stuck, write down the result you were missing as an assumption and move on: almost all of them can be solved with the previous one given.
What is examined: topic by topic
| Topic | Part | Theory | Proofs | Exercises |
|---|---|---|---|---|
| Descriptive statistics | 1 | Theory | Proofs | Exercises |
| Probability | 1 | Theory | Proofs | Exercises |
| Discrete random variables | 1 | Theory | Proofs | Exercises |
| Continuous random variables | 1 | Theory | Proofs | Exercises |
| The normal distribution | 2 | Theory | Proofs | Exercises |
| Transformations and joint distributions | 2 | Theory | Proofs | Exercises |
| Inequalities and limit theorems | 2 | Theory | Proofs | Exercises |
| Sampling distributions | 2 | Theory | Proofs | Exercises |
| Point estimation | 2 | Theory | Proofs | Exercises |
| Properties of estimators | 2 | Theory | Proofs | Exercises |
| Confidence intervals | 2 | Theory | Proofs | Exercises |
Common mistakes in the final
- as . It leaves out the 2: it is .
- The last class of the expected table. It must be «4 or more» (the tail ); otherwise the expected values do not add up to n and the chi-squared is wrong.
- Mixing up R’s geometric.
dgeomcounts failures before the first success: its mean is , not . - A continuous median with
integrateinsidecurve.curveneeds a vectorised function: plot f’s formula and leaveintegratefor F. - Applying the CLT without checking the variance. If , no CLT applies.
- Forgetting the Jacobian or the support in a change of variables. Draw the support of (U, V) before integrating: the pieces come from there.
- The MLE of with
var.vardivides by ; the MLE divides by . - Paired data as independent. Before and after on the same units:
t.test(after, before, paired = TRUE). - The pivot’s degrees of freedom. If ,
qchisqtakes , not . - Code in the console. Whatever is not in the
.Rdoes not exist for the marking.
Cheat sheet: what you can bring on your three sheets
The essentials in 30 seconds: if A and B are independent so are their complements; a density integrates to 1, its mean is and its median solves ; total probability and Bayes split by components; the mgf gives the moments by differentiating at 0 and ; the CLT turns a sum into a normal; a change of variables brings and a new support; the MLE comes from differentiating the log-likelihood and it is efficient if it attains the Cramér–Rao bound; and an interval is a pivot solved for the parameter.
| I want to… | How | In R |
|---|---|---|
| Independence | , and with , | — |
| Total probability and Bayes | ; | — |
| Density with K | ; ; | integrate(g, 0, 1) |
| Plot f and its median | vectorised f; | curve(f, 0, 1), uniroot(function(x) F(x) - 0.5, c(0.001, 0.999)) |
| Mixture of models | pexp, punif, pgamma | |
| Geometric (failures) | , | dgeom(x, p), pgeom(x, p) |
| Fit by the variance | (-1 + sqrt(1 + 4 * s2)) / (2 * s2) | |
| Observed and expected | table(cut(x, c(-1, 0, 1, 2, 3, Inf))), barplot(…, beside = TRUE) | |
| Sum of n exponentials | pgamma(t, n, la), qgamma(0.9, n, la) | |
| Series for masses | (even: cosh, odd: sinh), | long sums with x <- 0:100 |
| Moments with the mgf | , , | — |
| Chebyshev | ppois(b, la) - ppois(a - 1, la) | |
| CLT | if | pnorm(s, n * mu, sqrt(n * s2)) |
| Change of variables | ; integrate V piece by piece | integrate(function(v) …, a, b) |
| MLE properties | unbiased ; consistent ; efficient: | replicate(10000, …) |
| Mean and variance of a normal | t and chi-squared | t.test(x, conf.level = 0.9), qchisq |
| Variance ratio and paired data | F; differences | var.test(x, y), t.test(y, x, paired = TRUE) |
| Exponential pivot | qchisq(c(a / 2, 1 - a / 2), 2 * n) / (2 * T) | |
| Uniform pivot | : | max(x) / a^(1 / n) |
| Two proportions | mean(x) - mean(y) | |
| Quantiles | sums of squared normals → ; ratios → F; with S → t | qchisq, qf, qt |
What to revise on the site
If a part comes out red, the «Revise this topic» link in its solution takes you to the exercises (or the proofs) of the topic that explains it. And before trying again:
- The mock exams for each part, which are shorter: the EC1 mock exam and the EC2 mock exam.
- Each topic’s exam-style exercises and proofs (table above).
- The R environment, to practice with your own script without installing anything.
- The ME1 calculator, to see what you are missing.
Summary
| What | What it is like |
|---|---|
| Formats | Part 1 (topics 1-4) or part 2 (topics 5-11): 3 hours and 50 points; whole subject: 4 hours and 100 points |
| Bonus | 2.5 in part 1, 5 in part 2 and 10 in the whole subject, on top |
| Material | Laptop with RStudio, a handwritten three-sheet cheat sheet and your .R; at the end the exam .R is uploaded |
| How the mock is marked | Boxes with two decimals (0.01 tolerance), check values, criteria in the proofs, «I worked it out on paper» |
| What the mark means | Part: 25 or more, part passed. Whole: 50 or more, passed (the mark is the score divided by 10) |
| Versions | A, B and C as in 2025-26; D with what did not come up |
Three ideas for exam day: only sit what you are missing (an EC with 25 is kept), draw the support before any change of variables and say which pivot you use in each interval: that already gives you half the part, and R does the rest.
Keep goingAll Statistics articlesDid this article help you? Here is how you can support SergioLearns →



