# Number of coins ncoins = 3 # Likelihoods probhead = c(0.5,0.9,1.00) # Prior of coins priorcoin = rep(1/ncoins,ncoins) nmax = 10 posts = NULL for (n in 1:nmax){ postcoin = priorcoin*probhead^n postcoin = postcoin/sum(postcoin) posts = rbind(posts,postcoin) } rownames(posts)=1:nmax colnames(posts)=1:ncoins round(posts,6) ts.plot(posts,xlab="Numer of tosses",ylab="Prob of all heads",col=1:ncoins,ylim=c(0,1),type="b") legend("topleft",legend=c("Pr(head)",probhead),col=c(0,1:ncoins),lty=1)