• Home
  • About R Trix
  • Teaching Resources
  • RTricks Library
  • Interactive Apps
  • Training Network
RTFR landingdist

R Code for Discrete Probability Example 5

dice<-rep(2:12,c(1:6,5:1))
table(dice)/36? # Probability distribution
dice
hist(dice,freq=FALSE,breaks=c(1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5),ylab="Probability",xlab="Sum of Dice",main="Probability Histogram of Two Dice Sum")
# Note: areas add to 1 because the width of the bars are 1 and probabilities add to 1.