### Simulate rolling a fair die. # There are six possible outcomes. Let x be the number of pips you see on each # roll of a fair die. n = 10000 x = sample(1:6,n,replace=T) br = (1:7)-0.5 par(mfcol=c(4,1)) hist(x[1:100],nclass=6,breaks=br,probability=T,main="relative frequency plot - roll one die") hist(x[1:500],nclass=6,breaks=br,probability=T,main="relative frequency plot - roll one die") hist(x[1:1000],nclass=6,breaks=br,probability=T,main="relative frequency plot - roll one die") hist(x[1:10000],nclass=6,breaks=br,probability=T,main="relative frequency plot - roll one die") p.obs = table(x)/n p.exp = c(1,1,1,1,1,1)/6 cbind(p.obs,p.exp)