########################################################## # Author: Oliver Elison Timm # Date: 2014-01-27 # # Purpose: Demonstration of Probability laws # Frequentist's approach to measure probability # # NOTE: uncomment the desired experiments below ########################################################## # use the random generator to draw numbers from 1 to 6 # ( our 6-sided rolling die) ntrial<-100 nside<-6 # vector with nside elements filled with 0 count<-rep(0,nside) for (i in 1:ntrial) { # we only pick the first element of this random sequence res<-sample(nside) event<-res[1] count[event]<-count[event]+1 } print("---------------------") print("frequency of events:") print(seq(1,nside,1)) print(count/ntrial) print(paste("theoretical probability P(e): 1/6",1/6))