In: Advanced Math
PART A
This is the case of Binomial Likelihood and if the prior and posterior are in the same family then they are called conjugate distributions.
Now, given Binomial Prior the conjugate would be beta distribution. The posterior beta distribution is
Beta(y+alpha,N-y+beta)
where y is the no. of left handed students, N is the sample size, alpha & beta are the parameters of Beta distribution.
Here, y = 2 and N = 18 so, Prior is Uniform(0,1)which is Beta(1,1) and hence, Posterior is Beta(y+alpha,N-y+beta) = Beta(3,17)
Posterior mean = (y+alpha)/(N+alpha+beta) = 0.15
Posterior Median =(y+alpha-1/3)/(N+alpha+beta-2/3) = 0.137931
Posterior Mode = (y+alpha-1)/(N+alpha+beta-2) = 0.11111
R-Script for Part A
> #---Part A
> a<-1
> b<-1
> y<-2
> N<-18
> mean <-(y+a)/(N+a+b)
> mean
[1] 0.15
> median<-(y+a-(1/3))/(N+a+b-(2/3))
> median
[1] 0.137931
> mode<-(y+a-1)/(N+a+b-2)
> mode
[1] 0.1111111
> p = seq(0,1, length=500)
> plot(p, dbeta(p, 3,17), ylab="density", type ="l", col=4,main
= "Beta(3,17)")
Part B
Now, let the prior beta distribution has mean equal to 0.125 which is the mean of 0.05 and .20. For choosing new alpha & beta parameters with mean 0.125 let the pseudo sample size be n, so the alpha and beta parameters become n*0.125,n*(1-0.125). Let us suppose n=1000 so alpha and beta are 125 and 875 respectively.
Posterior is Beta(y+alpha,N-y+beta) = Beta(127,891)
Posterior mean = (y+alpha)/(N+alpha+beta) = 0.1247544
Posterior Median =(y+alpha-1/3)/(N+alpha+beta-2/3) = 0.1245085
Posterior Mode = (y+alpha-1)/(N+alpha+beta-2) = 0.1417323
R-Script for Part B
> #---Part B
> aa<-127
> bb<-891
> amean<-aa/(aa+bb)
> amean
[1] 0.1247544
> amedian<-(aa-(1/3))/(aa+bb-(2/3))
> amedian
[1] 0.1245085
> amode<-(aa-1)/(bb-2)
> amode
[1] 0.1417323
> p = seq(0,1, length=500)
> plot(p, dbeta(p, 127,891), ylab="density", type ="l",
col=4,main = "Beta(127,891)")