ST903 Week9sol
ST903 Week9sol
E(θ)(1 − E(θ))
α+β = − 1 = 1.67
Var(θ)
α = (α + β)E(θ) = 1, and
1.b. Let X1 , . . . , X1000 ∼ Bernoulli(θ). Here, n = 1000 and Xj = 1 if the person supports the death
P
penalty, and Xj = 0 if otherwise. Thus, Xj = 650. From the lecture, the posterior distribution for θ|X is
Beta(α + 650, β + 350) = Beta(651, 350.67). Thus, the posterior mean is 0.6499 and the posterior variance is
0.015.
2. Throughout, we will use the following identity for completing the square: ax2 − 2bx = a(x − b/a)2 − b2 /a.
2.a. Let Y1 , . . . , Yn ∼ N (θ, σ 2 ), and suppose we have the normal prior θ ∼ N (µ, τ 2 ). Here, σ = 20, µ = 180,
π(θ|Y) ∝ f (Y|θ)π(θ)
1 X 1
∝ exp − 2 (Yj − θ)2 exp − 2 (θ − µ)2
2σ 2τ
1 X 1
∝ exp − 2 (−2Yj θ + θ2 ) − 2 (θ2 − 2µθ)
2σ 2τ
1 1
∝ exp − 2 (−2nȲn θ + nθ2 ) − 2 (θ2 − 2µθ)
2σ 2τ
1
∝ exp − 2 2 (σ 2 + nτ 2 )θ2 − 2(nτ 2 Ȳn + σ 2 µ)θ
2σ τ
σ 2 + nτ 2
2
nτ Ȳn + σ 2 µ
∝ exp − θ −
2σ 2 τ 2 σ 2 + nτ 2
nτ 2 Ȳn + σ 2 µ
σ 2 + nτ 2
1
and variance
σ2 τ 2
σ 2 + nτ 2
2.b. Let ψ and φ2 be the mean and variance of θ|Y, respectively. Then
Z Z
1 2 1 2
f (ỹ|θ)π(θ|Y)dθ ∝ exp − 2 (ỹ − θ) exp − 2 (θ − ψ) dθ
2σ 2φ
Z
1 2 1 2 2 2 2 2
∝ exp − 2 ỹ exp − 2 2 (φ + σ )θ − 2(φ ỹ + σ ψ)θ dθ
2σ 2σ φ
(φ2 ỹ + σ 2 ψ)2
1 2 1
∝ exp − 2 ỹ exp − 2 2 −
2σ 2σ φ φ2 + σ 2
4
φ2 σ 2 ψ
1 2 φ 2
∝ exp − 2 2 φ − 2 ỹ − 2 ỹ
2σ φ φ + σ2 φ + σ2
1
∝ exp − (ỹ − ψ)2
2(σ 2 + φ2 )
nτ 2 Ȳn +σ 2 µ σ2 τ 2
Thus, Ỹ |Y is normally distributed with mean ψ = σ 2 +nτ 2 and variance σ 2 + φ2 = σ 2 + σ 2 +nτ 2 .
2.c. To create the intervals for the posterior distribution and the posterior predictive distribution, we use
the fact that these distributions are normal with their respective mean and variance specified above. For
n = 10, the posterior interval is (138.5,163.0) and the predictive interval is (109.7,191.8). For n = 100, these