Level 5 — MasteryProbability Theory & Statistics

Probability Theory & Statistics

2 minutes60 marksprintable — key stays hidden on paper

Time limit: 2 hours 30 minutes Total marks: 60 Instructions: Answer all three questions. Full rigour is expected: state theorems used, justify limit interchanges, and give clean derivations. Coding answers may be written in Python/NumPy-style pseudocode but must be executable-precise.


Question 1 — MGFs, CLT and a Monte Carlo estimator (20 marks)

Let X1,X2,X_1, X_2, \dots be i.i.d. random variables with XiExponential(λ)X_i \sim \text{Exponential}(\lambda), i.e. density f(x)=λeλxf(x) = \lambda e^{-\lambda x} for x0x \ge 0.

(a) Derive the moment generating function MX(t)M_X(t), stating its domain of convergence. Use it to obtain E[X]\mathbb{E}[X] and Var(X)\operatorname{Var}(X). (4)

(b) Let Sn=i=1nXiS_n = \sum_{i=1}^n X_i. Prove from MGFs that SnGamma(n,λ)S_n \sim \text{Gamma}(n,\lambda), and hence write down E[Sn]\mathbb{E}[S_n] and Var(Sn)\operatorname{Var}(S_n). (4)

(c) State the Central Limit Theorem for Xˉn=Sn/n\bar X_n = S_n/n. Using the MGF (or characteristic function) approach, give a proof sketch that the standardized sum converges to N(0,1)N(0,1), being explicit about the Taylor expansion step and where the i.i.d. assumption is used. (6)

(d) A colleague estimates θ=E[g(X)]\theta = \mathbb{E}[g(X)] for some bounded function gg by Monte Carlo: θ^N=1Ni=1Ng(Xi)\hat\theta_N = \frac1N \sum_{i=1}^N g(X_i). Prove θ^N\hat\theta_N is unbiased and consistent, and show its standard error scales as N1/2N^{-1/2}. Write a short vectorized code snippet that returns θ^N\hat\theta_N and an approximate 95% confidence interval for θ\theta. (6)


Question 2 — Estimation, information and confidence (20 marks)

Let Y1,,YnY_1, \dots, Y_n be i.i.d. Poisson(μ)\text{Poisson}(\mu).

(a) Write the log-likelihood, derive the MLE μ^\hat\mu, and confirm it via the method of moments. (4)

(b) Show μ^\hat\mu is unbiased. Compute the Fisher information In(μ)I_n(\mu) for the sample and state the Cramér–Rao lower bound. Is μ^\hat\mu efficient? Justify. (6)

(c) Using the CLT, derive an approximate (1α)(1-\alpha) confidence interval for μ\mu based on μ^\hat\mu. Then give the numeric 95% interval when n=100n=100 and Yi=250\sum Y_i = 250 (use z0.975=1.96z_{0.975}=1.96). (5)

(d) A Bayesian analyst places a Gamma(a,b)\text{Gamma}(a,b) prior on μ\mu (shape aa, rate bb). Derive the posterior distribution, identify the posterior mean, and show it is a weighted average of the prior mean and the MLE. State the limiting behaviour as nn\to\infty. (5)


Question 3 — Joint distributions, transformation and regression (20 marks)

Let (X,Y)(X,Y) have joint density f(x,y)=c(x+y),0x1, 0y1,f(x,y) = c\,(x+y), \qquad 0 \le x \le 1,\ 0 \le y \le 1, and f=0f=0 otherwise.

(a) Find cc, the marginal fX(x)f_X(x), and determine whether XX and YY are independent. (4)

(b) Compute E[X]\mathbb{E}[X], Var(X)\operatorname{Var}(X), Cov(X,Y)\operatorname{Cov}(X,Y) and the correlation ρ(X,Y)\rho(X,Y). (6)

(c) Let U=X+YU = X + Y. Using the change-of-variable / convolution technique, derive the density fU(u)f_U(u) on [0,2][0,2]. Verify it integrates to 1. (5)

(d) In a simple linear regression yi=β0+β1xi+εiy_i = \beta_0 + \beta_1 x_i + \varepsilon_i with εiN(0,σ2)\varepsilon_i \sim N(0,\sigma^2) i.i.d., derive the least-squares estimators β^0,β^1\hat\beta_0,\hat\beta_1 and prove β^1\hat\beta_1 is unbiased. State (no full proof needed) the sampling distribution of β^1\hat\beta_1 used to test H0:β1=0H_0:\beta_1=0. (5)


End of paper.

Answer keyMark scheme & solutions

Question 1

(a) [4] MX(t)=E[etX]=0λe(λt)xdx=λλtM_X(t)=\mathbb E[e^{tX}]=\int_0^\infty \lambda e^{-(\lambda-t)x}dx = \dfrac{\lambda}{\lambda-t} for t<λt<\lambda (integral converges only then). [2] M(t)=λ(λt)2M'(t)=\lambda(\lambda-t)^{-2}, so E[X]=M(0)=1/λ\mathbb E[X]=M'(0)=1/\lambda. M(t)=2λ(λt)3M''(t)=2\lambda(\lambda-t)^{-3}, E[X2]=2/λ2\mathbb E[X^2]=2/\lambda^2, hence Var(X)=2/λ21/λ2=1/λ2\operatorname{Var}(X)=2/\lambda^2-1/\lambda^2=1/\lambda^2. [2]

(b) [4] By independence MSn(t)=iMXi(t)=(λλt)nM_{S_n}(t)=\prod_i M_{X_i}(t)=\left(\frac{\lambda}{\lambda-t}\right)^n. [2] This is exactly the MGF of Gamma(n,λ)\text{Gamma}(n,\lambda) (shape nn, rate λ\lambda); MGFs uniquely determine distributions, so SnGamma(n,λ)S_n\sim\text{Gamma}(n,\lambda). [1] Thus E[Sn]=n/λ\mathbb E[S_n]=n/\lambda, Var(Sn)=n/λ2\operatorname{Var}(S_n)=n/\lambda^2. [1]

(c) [6] CLT statement: Zn=Xˉnμσ/n=SnnμσndN(0,1)Z_n=\dfrac{\bar X_n-\mu}{\sigma/\sqrt n}=\dfrac{S_n-n\mu}{\sigma\sqrt n}\xrightarrow{d}N(0,1) with μ=1/λ, σ=1/λ\mu=1/\lambda,\ \sigma=1/\lambda. [2] Sketch: Let Wi=(Xiμ)/σW_i=(X_i-\mu)/\sigma, mean 0, variance 1. MGF MW(t)=1+t22+o(t2)M_W(t)=1+\tfrac{t^2}{2}+o(t^2) (from Taylor expansion, using EW=0, EW2=1\mathbb E W=0,\ \mathbb E W^2=1). [2] By independence the MGF of Zn=1nWiZ_n=\frac1{\sqrt n}\sum W_i is (MW(t/n))n=(1+t22n+o(1/n))net2/2\left(M_W(t/\sqrt n)\right)^n=\left(1+\frac{t^2}{2n}+o(1/n)\right)^n\to e^{t^2/2}, the N(0,1)N(0,1) MGF; convergence of MGFs on a neighbourhood of 0 \Rightarrow convergence in distribution (Lévy/continuity theorem). The i.i.d. assumption is used to factor the joint MGF into the nn-th power and to use a common MWM_W. [2]

(d) [6] Unbiased: E[θ^N]=1NE[g(Xi)]=θ\mathbb E[\hat\theta_N]=\frac1N\sum\mathbb E[g(X_i)]=\theta. [1] Consistency: Var(θ^N)=σg2/N0\operatorname{Var}(\hat\theta_N)=\sigma_g^2/N\to0 where σg2=Var(g(X))<\sigma_g^2=\operatorname{Var}(g(X))<\infty (bounded gg); by WLLN (or Chebyshev) θ^NPθ\hat\theta_N\xrightarrow{P}\theta. [2] SE =σg/N=O(N1/2)=\sigma_g/\sqrt N=O(N^{-1/2}). [1] Code: [2]

import numpy as np
def mc_estimate(g, sampler, N, rng):
    x = sampler(N, rng)          # draws X_i
    vals = g(x)                  # vectorized g
    theta_hat = vals.mean()
    se = vals.std(ddof=1)/np.sqrt(N)
    ci = (theta_hat - 1.96*se, theta_hat + 1.96*se)
    return theta_hat, ci

Question 2

(a) [4] (μ)=i(μ+YilnμlnYi!)=nμ+lnμYiconst\ell(\mu)=\sum_i(-\mu+Y_i\ln\mu-\ln Y_i!) = -n\mu+\ln\mu\sum Y_i - \text{const}. [2] (μ)=n+Yiμ=0μ^=Yˉ\ell'(\mu)=-n+\frac{\sum Y_i}{\mu}=0\Rightarrow\hat\mu=\bar Y. Second derivative Yi/μ2<0-\sum Y_i/\mu^2<0 so it is a max. [1] MoM: population mean =μ=\mu, set equal to sample mean μ^=Yˉ\Rightarrow \hat\mu=\bar Y — same. [1]

(b) [6] E[μ^]=1nE[Yi]=μ\mathbb E[\hat\mu]=\frac1n\sum\mathbb E[Y_i]=\mu ⇒ unbiased. [1] Per-observation info: E[μ2lnf]-\mathbb E[\partial^2_\mu \ln f]. lnf=μ+YlnμlnY!\ln f=-\mu+Y\ln\mu-\ln Y!, μ2=Y/μ2\partial^2_\mu=-Y/\mu^2, E[Y/μ2]=μ/μ2=1/μ-\mathbb E[-Y/\mu^2]=\mu/\mu^2=1/\mu. So I1(μ)=1/μI_1(\mu)=1/\mu and In(μ)=n/μI_n(\mu)=n/\mu. [3] CRLB =1/In(μ)=μ/n=1/I_n(\mu)=\mu/n. [1] Var(μ^)=Var(Yˉ)=μ/n\operatorname{Var}(\hat\mu)=\operatorname{Var}(\bar Y)=\mu/n attains the bound ⇒ μ^\hat\mu is efficient (MVUE). [1]

(c) [5] By CLT μ^N(μ,μ/n)\hat\mu\approx N(\mu,\mu/n), and Var^=μ^/n\widehat{\operatorname{Var}}=\hat\mu/n. [1] CI: μ^±z1α/2μ^/n\hat\mu\pm z_{1-\alpha/2}\sqrt{\hat\mu/n}. [2] Numeric: μ^=250/100=2.5\hat\mu=250/100=2.5, SE =2.5/100=0.025=0.15811=\sqrt{2.5/100}=\sqrt{0.025}=0.15811. Margin =1.96×0.15811=0.30990=1.96\times0.15811=0.30990. CI (2.190,2.810)\approx(2.190,\,2.810). [2]

(d) [5] Posterior \propto likelihood ×\times prior μYienμμa1ebμ=μa+Yi1e(b+n)μ\propto \mu^{\sum Y_i}e^{-n\mu}\cdot \mu^{a-1}e^{-b\mu}=\mu^{a+\sum Y_i-1}e^{-(b+n)\mu}. [2] So posterior =Gamma(a+Yi, b+n)=\text{Gamma}(a+\sum Y_i,\ b+n). [1] Posterior mean =a+Yib+n=bb+nab+nb+nYˉ=\dfrac{a+\sum Y_i}{b+n}=\dfrac{b}{b+n}\cdot\frac{a}{b}+\dfrac{n}{b+n}\cdot\bar Y — a convex combination of prior mean a/ba/b and MLE Yˉ\bar Y. [1] As nn\to\infty the weight on Yˉ1\bar Y\to1, posterior mean μ^\to\hat\mu (data dominates). [1]


Question 3

(a) [4] 0101c(x+y)dxdy=c01(12+y)dy=c(12+12)=c=1c=1\int_0^1\int_0^1 c(x+y)\,dx\,dy = c\int_0^1(\tfrac12+y)dy=c(\tfrac12+\tfrac12)=c=1\Rightarrow c=1. [2] fX(x)=01(x+y)dy=x+12, 0x1f_X(x)=\int_0^1(x+y)dy=x+\tfrac12,\ 0\le x\le1 (same form for fYf_Y). [1] Since f(x,y)=x+y(x+12)(y+12)=fXfYf(x,y)=x+y\ne (x+\tfrac12)(y+\tfrac12)=f_X f_Y, they are not independent. [1]

(b) [6] E[X]=01x(x+12)dx=13+14=712\mathbb E[X]=\int_0^1 x(x+\tfrac12)dx=\tfrac13+\tfrac14=\tfrac{7}{12}. [1] E[X2]=01x2(x+12)dx=14+16=512\mathbb E[X^2]=\int_0^1 x^2(x+\tfrac12)dx=\tfrac14+\tfrac16=\tfrac{5}{12}; Var(X)=512(712)2=6049144=11144\operatorname{Var}(X)=\tfrac{5}{12}-(\tfrac7{12})^2=\tfrac{60-49}{144}=\tfrac{11}{144}. [2] E[XY]=0101xy(x+y)dxdy= ⁣(x2y+xy2)=1312+1213=13\mathbb E[XY]=\int_0^1\int_0^1 xy(x+y)dxdy=\int\!\int (x^2y+xy^2)=\tfrac13\cdot\tfrac12+\tfrac12\cdot\tfrac13=\tfrac13. [1] Cov=13(712)2=4849144=1144\operatorname{Cov}=\tfrac13-(\tfrac7{12})^2=\tfrac{48-49}{144}=-\tfrac1{144}. [1] ρ=1/14411/144=111\rho=\dfrac{-1/144}{11/144}=-\tfrac{1}{11}. [1]

(c) [5] fU(u)=f(x,ux)dxf_U(u)=\int f(x,u-x)dx over valid region. For 0u10\le u\le1: x[0,u]x\in[0,u], integrand =u=ufU(u)=0uudx=u2f_U(u)=\int_0^u u\,dx=u^2. [2] For 1u21\le u\le2: x[u1,1]x\in[u-1,1], length 2u2-u, integrand =u=ufU(u)=u(2u)f_U(u)=u(2-u). [2] Check: 01u2du+12u(2u)du=13+[u2u33]12=13+(483)(113)=13+4323=1.\int_0^1 u^2du+\int_1^2 u(2-u)du=\tfrac13+\big[u^2-\tfrac{u^3}{3}\big]_1^2=\tfrac13+(4-\tfrac83)-(1-\tfrac13)=\tfrac13+\tfrac43-\tfrac23=1.[1]

(d) [5] Minimize (yiβ0β1xi)2\sum(y_i-\beta_0-\beta_1 x_i)^2. Normal equations give β^1=(xixˉ)(yiyˉ)(xixˉ)2=SxySxx\hat\beta_1=\dfrac{\sum(x_i-\bar x)(y_i-\bar y)}{\sum(x_i-\bar x)^2}=\dfrac{S_{xy}}{S_{xx}}, β^0=yˉβ^1xˉ\hat\beta_0=\bar y-\hat\beta_1\bar x. [2] Unbiasedness: β^1=wiyi\hat\beta_1=\sum w_i y_i with wi=(xixˉ)/Sxxw_i=(x_i-\bar x)/S_{xx}, wi=0, wixi=1\sum w_i=0,\ \sum w_i x_i=1. Then E[β^1]=wi(β0+β1xi)=β00+β11=β1\mathbb E[\hat\beta_1]=\sum w_i(\beta_0+\beta_1x_i)=\beta_0\cdot0+\beta_1\cdot1=\beta_1. [2] Distribution: β^1N ⁣(β1, σ2/Sxx)\hat\beta_1\sim N\!\big(\beta_1,\ \sigma^2/S_{xx}\big); test H0:β1=0H_0:\beta_1=0 via t=β^1/(σ^/Sxx)tn2t=\hat\beta_1/(\hat\sigma/\sqrt{S_{xx}})\sim t_{n-2}. [1]

[
{"claim":"Exponential MGF gives mean 1/lambda, var 1/lambda^2","code":"t,lam,x=symbols('t lam x',positive=True); M=integrate(lam*exp(-(lam-t)*x),(x,0,oo)); M=simplify(M.rewrite(Piecewise)); Mf=lam/(lam-t); mean=diff(Mf,t).subs(t,0); ex2=diff(Mf,t,2).subs(t,0); var=simplify(ex2-mean**2); result=(simplify(mean-1/lam)==0 and simplify(var-1/lam**2)==0)"},
{"claim":"Poisson 95% CI endpoints ~ (2.190,2.810)","code":"mu=Rational(25,10); se=sqrt(mu/100); lo=float(mu-1.96*se); hi=float(mu+1.96*se); result=(abs(lo-2.190)<0.01 and abs(hi-2.810)<0.01)"},
{"claim":"Joint density: Var(X)=11/144, Cov=-1/144, rho=-1/11","code":"x,y=symbols('x y'); fX=x+Rational(1,2); EX=integrate(x*fX,(x,0,1)); EX2=integrate(x**2*fX,(x,0,1)); VarX=EX2-EX**2; EXY=integrate(integrate(x*y*(x+y),(x,0,1)),(y,