HWS8

ST 380: Probability and Statistics for the Physical Sciences
Solution to Homework Assignment - 8
Prepared by Liwei Wang
Fall, 2009
Ch.2-Ex.28: (a)
i. Here, prior distribution of θ ∼ N (0, 1). Hence,
p(θ|y) ∝ p(θ|y)p(θ)
2 (y − θ)2
θ
1
1
√ exp −
√ exp −
=
2
2
2π
2π
2
2
−θ
(y − θ)
∝ exp −
exp
2
2
)
(
2
θ2 − yθ + y2
= exp −
2 ∗ 12
(θ − y2 )2
∝ exp −
2 ∗ 12
o
n
o
n
2
(z−µ)2
1
∝
exp
−
. Here
If Z ∼ N (µ, σ), then p(z) = √2πσ
exp − (z−µ)
2σ 2
2σ 2
n
y 2o
(θ− )
p(θ|y) ∝ exp − 2∗21 , So
2
n
1
y o
p(θ|y) = √ exp −(θ − )2
2
π
q
y
ii. Refer to part (i), θ|y ∼ N ( 2 , 12 ) is a normal distribution.
q
iii. Mean is y2 , SD is 12 .
ST 380: HWS8
Page 1
c
Sujit
Ghosh, NCSU Statistics
(b)
i. Here, prior distribution of θ ∼ N (m, σ). Hence,
p(θ|y) ∝ p(θ|y)p(θ)
1
1
(y − θ)2
(θ − m)2
√ exp −
= √ exp −
2σy2
2σ 2
2π
2π
(θ − m)2
(y − θ)2
exp
−
∝ exp −
2σy2
2σ 2
−(y − θ)2 σ 2 − (θ − m)2 σy2
= exp
2σy2 σy2
(σ 2 + σy2 )θ2 − 2(yσ 2 + mσy2 )θ
∝ exp −
2σy2 σy2

2
2 
y
 θ2 − 2 yσσ2+mσ
θ
+σy2
= exp −
σ2 σ2


2 σ2y+σy2
y


2
2
y 2
 (θ − yσσ2+mσ

)
+σy2
∝ exp
σ2 σ2


2 σ2y+σy2
y
n
o
n
o
2
(z−µ)2
1
If Z ∼ N (µ, σ), then p(z) = √2πσ
exp − (z−µ)
∝
exp
−
. Here
2
2
2σ
2σ


2
2
 (θ− yσ 2+mσ2 y )2 
σ +σy
.So
p(θ|y) ∝ exp
2 σ2
y

 2 σσ2y+σ
2
y
1
p(θ|y) = q
σ2 σ2
2π σ2y+σy2
y


2
2
y 2

 (θ − yσσ2+mσ
)
+σy2
exp −
yσ 2 +mσ 2

2 σ2 +σ2 y 
yσ 2 +mσ 2
ii. Refer to part (i), θ|y ∼ N ( σ2 +σ2 y ,
q 2 2 y
yσ 2 +mσy2
σ σ
iii. Mean is σ2 +σ2 , SD is σ2y+σy2 .
y
ST 380: HWS8
y
q
σy2 σy2
)
σ 2 +σy2
is a normal distribution.
y
Page 2
c
Sujit
Ghosh, NCSU Statistics
(c)
i. Here, prior distribution of θ ∼ N (m, σ). Hence,
p(θ|y1 , . . . , yn ) ∝ p(θ|y1 , . . . , yn )p(θ)
Pn
2
1 n
1
(θ − m)2
i=1 (yi − θ)
√ exp −
= ( √ ) exp −
2σy2
2σ 2
2π
2π
Pn
(yi − θ)2
(θ − m)2
exp −
∝ exp − i=1 2
2σy
2σ 2
Pn
− i=1 (yi − θ)2 σ 2 − (θ − m)2 σy2
= exp
2σy2 σy2
P
(nσ 2 + σy2 )θ2 − 2( ni=1 yi σ 2 + mσy2 )θ
∝ exp −
2σy2 σy2
Pn

2
2 
y
 θ2 − 2 i=1nσy2i σ+σ+mσ
θ
2
y
= exp −
σ2 σ2


2 nσ2y+σy 2
y
Pn


2
2
y 2
 (θ − i=1nσy2i σ+σ+mσ
) 
2
y
∝ exp
2 σ2
σ


2 nσ2y+σy 2
y
o
n
o
n
2
(z−µ)2
1
∝
exp
−
. Here
If Z ∼ N (µ, σ), then p(z) = √2πσ
exp − (z−µ)
2
2
2σ
2σ
 Pn

2
2
y 2
 (θ− i=1 y2i σ +mσ
)
2
nσ +σy
p(θ|y) ∝ exp
. So,
σ2 σ2


2 2y y 2
nσ +σ
y
1
q
σ2 σ2
2π nσ2y+σy 2
y
Pn


2
2
y 2
 (θ − i=1nσy2i σ+σ+mσ
) 
2
y
exp −
2 σ2
σ


2 nσ2y+σy 2
y
Pn
y σ 2 +mσ 2
ii. Refer to part (i), θ|y ∼ N ( i=1nσ2i +σ2 y ,
y
tion.
q
Pn
y σ 2 +mσ 2
σ2 σ2
iii. Mean is i=1nσ2i +σ2 y , SD is nσ2y+σy 2 .
y
q
σy2 σy2
)
nσ 2 +σy2
is a normal distribu-
y
Ch2.Ex30 R codes;
> pnorm(-0.72,-2,1)
[1] 0.8997274
> pnorm(-0.36,-2,1)-pnorm(-3.65,-2,1)
[1] 0.900026
> 1-pnorm(-3.28,-2,1)
[1] 0.8997274
From the R output, we can see that the three intervals are 90% prediction intervals.
R codes;
ST 380: HWS8
Page 3
c
Sujit
Ghosh, NCSU Statistics
> qnorm(0.8,-2,1)
[1] -1.158379
> qnorm(c(0.1,0.9),-2,1)
[1] -3.2815516 -0.7184484
> qnorm(0.2,-2,1)
[1] -2.841621
From the R output, we can see that the corresponding 80% prediction intervals are
(−∞, −1.16], [−3.28, −0.72], and [−2.84, +∞).
Ch2.Ex35 Asiago: nA = 100, LS.1 set
Brie: nB = 400, LS.1 set
Cheshire: nC = 100, LS.2 set
In general, notice that for any α ∈ (0, 1),
LSα = {θ : l(θ) ≥ αl(θ̂)}
n(θ − θ̂)2
} ≥ α} (using CLT)
2σ 2
p
σ
= {θ : |θ − θ̂| ≤ −2 log(α) √ }
n
i
h
p
p
σ
σ
√
√
Hence, LSα ≈ θ̂ − −2 log(α) n , θ̂ + −2 log(α) n for any α ∈ (0, 1).
p
Thus, length of LSα is approximately −2 log(α) √2σn
≈ {θ : exp{
(a) For Asiago,
p nA = 1002σand αA = 0.1 and hence the length of LS0.1 is approximately −2 log(0.1) nA = 0.4292σ.
For Brie,
αB = 0.1 and hence the length of LS0.1 is approxipnB = 400 and
2σ
mately −2 log(0.1) nB = 0.2146σ.
Hence, Asiago will have a longer interval and the interval will be about twice
(b/c .4292/0.2146 = 2) the length of that of Brie.
(b) For Chesire,
p nC = 1002σand αC = 0.2 and hence the length of LS0.2 is approximately −2 log(0.2) nC = 0.3588σ.
Hence, Asiago will have a longer interval and the interval will be about 1.2
times (b/c .4292/0.3588 = 1.196) the length of that of Chesire.
Ch.2-Ex.36 y is supposed to represent sample of size 15 from the exponential distribution with
mean 100.
(lo, hi) is supposed to represent a 95% confidence interval for the population
mean. estimated from the sample.
n/1000 is supposed to represent the approximate proportion of the times the interval estimate will contain the (true) population mean.
If a sample size of 15 is sufficiently large enough for the Central Limit Theorem to
ST 380: HWS8
Page 4
c
Sujit
Ghosh, NCSU Statistics
apply, then approximately the value of n/1000 should be 0.95.
Here is the result after running the loop:
> n<-0
> for (i in 1:1000){
+ y<-rexp(15,0.01)
+ m<-mean(y)
+ s<-sqrt(var(y)/15)
+ lo<-m-2*s
+ hi<-m+2*s
+ if(lo<100 & hi>100 ) n<-n+1
+ }
> print(n/1000)
[1] 0.901
Remark: Note the correction that we made to the formula for s<-sqrt(var(y))/15),
the division by 15 was missing. Also the end result of 0.901 is a random solution
and may not match with your solution unless you fix the seed of random number
generator.
ST 380: HWS8
Page 5
c
Sujit
Ghosh, NCSU Statistics