#prior first scientist# sd0 <- 20 phi0 <- sd0^2 theta0 <- 370 z=seq(200,600,by=1) y0=dnorm(z,theta0,sd0) plot(z,y0,type="l",ylim=c(0,0.054)) #likelihood# sdobs <- 8 phi <- sdobs^2 x <- 421 #posterior first scientist# phi1 <- (phi0^(-1) + phi^(-1))^(-1) sd1 <- sqrt(phi1) theta1 <- phi1*(theta0/phi0 + x/phi) cat("First scientist has posterior mean",theta1,"and s.d.",sd1,".\n") y1=dnorm(z,theta1,sd1) lines(z,y1) #prior second scientist# sd0hat <- 50 phi0hat <- sd0hat^2 theta0hat <- 400 y0hat=dnorm(z,theta0hat,sd0hat) lines(z,y0hat,lty=4) #posterior second scientist# phi1hat <- (phi0hat^(-1) + phi^(-1))^(-1) sd1hat <- sqrt(phi1hat) theta1hat <- phi1*(theta0hat/phi0 + x/phi) cat("Second scientist has posterior mean",theta1hat,"and s.d.",sd1hat,".\n") y1hat=dnorm(z,theta1hat,sd1hat) lines(z,y1hat,lty=4)