#------------------------------------------------------------------- # sum and difference of the numbers resulting from tossing two dice # # GdA, 29/1/2016 #------------------------------------------------------------------- salva = ! TRUE if(salva) postscript(file="distr_due_dadi.eps",onefile=FALSE,horizontal=FALSE, height=4,width=8,pointsize=11) par(mfrow = c(1,2)) sum = outer(1:6, 1:6, '+') barplot(table(sum)/36, col='cyan', xlab='s', ylab='f(s)', main='sum two dice') dif = outer(1:6, 1:6, '-') barplot(table(dif)/36, col='magenta', xlab='d', ylab='f(d)', main='difference two dice') par(mfrow = c(1,1)) if(salva) dev.off()