Level 4 — ApplicationProbability & Statistics

Probability & Statistics

50 marksprintable — key stays hidden on paper

Level 4 — Application (novel problems, no hints) Time: 60 minutes Total Marks: 50

Answer all questions. Show full working. Use ...... for mathematical notation. Standard normal values you may use: Φ(1.645)=0.95\Phi(1.645)=0.95, Φ(1.96)=0.975\Phi(1.96)=0.975, Φ(1)=0.8413\Phi(1)=0.8413.


Question 1 — Bayesian diagnostics & information (12 marks)

A spam filter classifies emails. From training data, 30%30\% of incoming emails are spam. A word "FREE" appears in 60%60\% of spam emails and in 10%10\% of legitimate emails.

(a) An email contains "FREE". Compute the posterior probability that it is spam. (4)

(b) Two independent word-features are now used: "FREE" (as above) and "WINNER" which appears in 50%50\% of spam and 5%5\% of legitimate emails. Assuming conditional independence of the two words given the class, compute the posterior probability of spam for an email containing both words. (5)

(c) Compute the entropy (in bits) of the prior class distribution (spam vs legitimate). (3)


Question 2 — MLE for an exponential model (10 marks)

Server response times (in seconds) are modelled as i.i.d. Exponential(λ)\text{Exponential}(\lambda) with density f(x)=λeλxf(x)=\lambda e^{-\lambda x}, x0x\ge 0.

(a) Derive the maximum likelihood estimator λ^\hat\lambda for a sample x1,,xnx_1,\dots,x_n. (4)

(b) A sample of n=5n=5 gives observations 0.5,1.0,2.0,1.5,0.50.5, 1.0, 2.0, 1.5, 0.5 seconds. Compute λ^\hat\lambda. (2)

(c) Using your fitted model, compute P(X>2)P(X > 2). (2)

(d) State (with brief justification) whether λ^\hat\lambda is the reciprocal of the sample mean, and what the MLE of the mean response time is. (2)


Question 3 — Sums, CLT and a probability bound (10 marks)

A factory produces bolts whose lengths are i.i.d. with mean μ=10\mu = 10 mm and standard deviation σ=0.4\sigma = 0.4 mm. A box contains n=100n = 100 bolts.

(a) Let Xˉ\bar X be the sample mean length. State the approximate distribution of Xˉ\bar X and give its mean and standard deviation. (3)

(b) Compute the approximate probability that Xˉ\bar X exceeds 10.0510.05 mm. (3)

(c) Give a symmetric 95%95\% interval for Xˉ\bar X centred on 1010 mm. (2)

(d) A colleague claims the exact distribution of individual bolt lengths must be Normal for part (a) to hold. Is this correct? Justify in one sentence. (2)


Question 4 — Joint distribution, covariance, correlation (10 marks)

Discrete random variables X,YX,Y have joint pmf given by the table:

X\YX\backslash Y 00 11
00 0.10.1 0.20.2
11 0.30.3 0.40.4

(a) Find the marginal pmfs of XX and YY. (2)

(b) Are XX and YY independent? Justify. (3)

(c) Compute Cov(X,Y)\operatorname{Cov}(X,Y). (3)

(d) Compute the correlation coefficient ρXY\rho_{XY}. (2)


Question 5 — Hypothesis test & confidence interval (8 marks)

A new model achieves accuracy on n=400n=400 test items. It is correct on 340340 of them. The previous model had a known accuracy of 0.800.80.

(a) Estimate the new model's accuracy p^\hat p and its standard error. (2)

(b) Test H0:p=0.80H_0: p = 0.80 vs H1:p>0.80H_1: p > 0.80 at the 5%5\% level using a one-sided z-test. State the z-statistic and conclusion. (4)

(c) Construct an approximate 95%95\% confidence interval for pp. (2)

Answer keyMark scheme & solutions

Question 1

(a) Bayes. Let SS=spam, FF="FREE". P(S)=0.3, P(FS)=0.6, P(FSˉ)=0.1P(S)=0.3,\ P(F|S)=0.6,\ P(F|\bar S)=0.1. (1) P(F)=0.6(0.3)+0.1(0.7)=0.18+0.07=0.25P(F)=0.6(0.3)+0.1(0.7)=0.18+0.07=0.25. (1) P(SF)=0.180.25=0.72P(S|F)=\dfrac{0.18}{0.25}=0.72. (2)

(b) With conditional independence, P(F,WS)=0.6×0.5=0.3P(F,W|S)=0.6\times0.5=0.3; P(F,WSˉ)=0.1×0.05=0.005P(F,W|\bar S)=0.1\times0.05=0.005. (2) Numerator: 0.3×0.3=0.090.3\times0.3=0.09. (1) Evidence: 0.09+0.005×0.7=0.09+0.0035=0.09350.09+0.005\times0.7=0.09+0.0035=0.0935. (1) P(SF,W)=0.09/0.09350.9626P(S|F,W)=0.09/0.0935\approx 0.9626. (1)

(c) H=0.3log20.30.7log20.7H=-0.3\log_2 0.3 - 0.7\log_2 0.7. (1) =0.3(1.737)0.7(0.5146)=0.5211+0.3602=0.8813=-0.3(-1.737)-0.7(-0.5146)=0.5211+0.3602=0.8813 bits. (2)


Question 2

(a) Likelihood L=λeλxi=λneλxiL=\prod \lambda e^{-\lambda x_i}=\lambda^n e^{-\lambda\sum x_i}. (1) Log-likelihood =nlnλλxi\ell=n\ln\lambda-\lambda\sum x_i. (1) ddλ=nλxi=0\frac{d\ell}{d\lambda}=\frac{n}{\lambda}-\sum x_i=0. (1) λ^=nxi=1xˉ\hat\lambda=\dfrac{n}{\sum x_i}=\dfrac{1}{\bar x} (second deriv n/λ2<0-n/\lambda^2<0 ⇒ max). (1)

(b) xi=0.5+1.0+2.0+1.5+0.5=5.5\sum x_i=0.5+1.0+2.0+1.5+0.5=5.5, n=5n=5. λ^=5/5.5=0.9091 s1\hat\lambda=5/5.5=0.9091\ \text{s}^{-1}. (2)

(c) P(X>2)=eλ^2=e1.8180.1623P(X>2)=e^{-\hat\lambda\cdot 2}=e^{-1.818}\approx 0.1623. (2)

(d) Yes — λ^=1/xˉ\hat\lambda=1/\bar x where xˉ=1.1\bar x=1.1; MLE of mean response time is 1/λ^=xˉ=1.11/\hat\lambda=\bar x=1.1 s (invariance of MLE). (2)


Question 3

(a) By CLT, XˉN ⁣(μ, σ2/n)\bar X \approx N\!\left(\mu,\ \sigma^2/n\right). Mean =10=10, SD =0.4/100=0.04=0.4/\sqrt{100}=0.04 mm. (3)

(b) z=10.05100.04=1.25z=\dfrac{10.05-10}{0.04}=1.25. (1) P(Xˉ>10.05)=1Φ(1.25)=10.8944=0.1056P(\bar X>10.05)=1-\Phi(1.25)=1-0.8944=0.1056. (2) (accept ≈0.106)

(c) 10±1.96(0.04)=10±0.078410 \pm 1.96(0.04)=10\pm0.0784, i.e. [9.9216, 10.0784][9.9216,\ 10.0784] mm. (2)

(d) Incorrect — the CLT gives an approximate Normal distribution for Xˉ\bar X regardless of the individual distribution (given finite variance and large nn); individual lengths need not be Normal. (2)


Question 4

(a) P(X=0)=0.1+0.2=0.3P(X=0)=0.1+0.2=0.3, P(X=1)=0.7P(X=1)=0.7. P(Y=0)=0.1+0.3=0.4P(Y=0)=0.1+0.3=0.4, P(Y=1)=0.6P(Y=1)=0.6. (2)

(b) Check P(X=0,Y=0)=0.1P(X=0,Y=0)=0.1 vs P(X=0)P(Y=0)=0.3×0.4=0.120.1P(X=0)P(Y=0)=0.3\times0.4=0.12\ne0.1. (2) Not independent. (1)

(c) E[X]=0.7E[X]=0.7, E[Y]=0.6E[Y]=0.6. (1) E[XY]=xyp=110.4=0.4E[XY]=\sum xy\,p = 1\cdot1\cdot0.4=0.4. (1) Cov=0.40.7×0.6=0.40.42=0.02\operatorname{Cov}=0.4-0.7\times0.6=0.4-0.42=-0.02. (1)

(d) Var(X)=0.70.49=0.21\operatorname{Var}(X)=0.7-0.49=0.21; Var(Y)=0.60.36=0.24\operatorname{Var}(Y)=0.6-0.36=0.24. ρ=0.020.21×0.24=0.020.224490.0891\rho=\dfrac{-0.02}{\sqrt{0.21\times0.24}}=\dfrac{-0.02}{0.22449}\approx -0.0891. (2)


Question 5

(a) p^=340/400=0.85\hat p=340/400=0.85. SE=p^(1p^)/n=0.850.15/400=0.000319=0.01786SE=\sqrt{\hat p(1-\hat p)/n}=\sqrt{0.85\cdot0.15/400}=\sqrt{0.000319}=0.01786. (2)

(b) Under H0H_0, SE0=0.80.2/400=0.0004=0.02SE_0=\sqrt{0.8\cdot0.2/400}=\sqrt{0.0004}=0.02. (1) z=0.850.800.02=2.5z=\dfrac{0.85-0.80}{0.02}=2.5. (2) Since 2.5>1.6452.5>1.645 (and p-value 0.0062<0.05\approx0.0062<0.05), reject H0H_0: significant improvement. (1)

(c) 0.85±1.96(0.01786)=0.85±0.0350=[0.8150, 0.8850]0.85\pm1.96(0.01786)=0.85\pm0.0350=[0.8150,\ 0.8850]. (2)


[
{"claim":"Q1a posterior spam given FREE = 0.72","code":"pS=Rational(3,10); pFS=Rational(6,10); pFnS=Rational(1,10); post=pFS*pS/(pFS*pS+pFnS*(1-pS)); result = (post==Rational(72,100))"},
{"claim":"Q1b posterior both words approx 0.9626","code":"num=0.3*0.3; den=num+0.005*0.7; result = abs(num/den-0.9626)<1e-3"},
{"claim":"Q2 exp MLE lambda=5/5.5 and P(X>2)","code":"lam=Rational(5,55)*10; result = (lam==Rational(10,11)) and abs(exp(-float(lam)*2)-0.1623)<1e-3"},
{"claim":"Q3b P(Xbar>10.05) approx 0.1056","code":"from sympy import erf; z=1.25; p=1-(0.5*(1+erf(z/sqrt(2)))); result = abs(float(p)-0.1056)<2e-3"},
{"claim":"Q4 covariance -0.02 and correlation approx -0.0891","code":"cov=0.4-0.7*0.6; rho=cov/sqrt(0.21*0.24); result = abs(cov+0.02)<1e-9 and abs(rho+0.0891)<1e-3"},
{"claim":"Q5 z-statistic = 2.5","code":"z=(0.85-0.80)/sqrt(0.8*0.2/400); result = abs(z-2.5)<1e-9"}
]