motif() theta_seq(0,1,length=5000) par(mfrow=c(4,5)) #examine beta densities for(i in c(1,5,10,20)) { for(j in c(1,5,10,20,100)) plot(theta,dbeta(theta,i,j)) } par(mfrow=c(2,3)) #sample posteriors for(i in 1:6) { y_rbinom(1,10*i,.2) plot(theta,dbeta(theta,y+1,10*i-y+1)) } #repeat par(mfrow=c(1,1)) #quantiles of the beta plot(theta,dbeta(theta,2,10)) abline(v=qbeta(0.5,2,10),col=2) abline(v=qbeta(0.025,2,10),col=2) abline(v=qbeta(0.975,2,10),col=2) x_runif(5000) y_qbeta(x,2,10) #sampling from the CDF hist(y,prob=T,nclass=25) lines(theta,dbeta(theta,2,10)) lines(theta[theta0)/5000 mean(d>0) quantile(d,prob=c(0.05,0.95))