# How to simulate a process and produce an animated histogram. # We consider the two examples presented here # [ dev.off() closes the last window ] # # The first: REP = function(n) { if(n>10) dev.off() D = c(2,1,1,1,1,0.5) dice = RUNIF2(n, 1,6,D) + RUNIF2(n, 1,6,D) hist(dice, seq(1.5,12.5,1),probability=TRUE,col="yellow") abline(h=seq(0.05,1,0.05), lty=3); print(N) } BF=4.5; HF=3.5 N=10; REP(N) N=N*2; REP(N) N=N*2; REP(N) ...# # The second: REP = function(n) { if(n>10) dev.off() dice = abs( RUNIF(n,1,6)-RUNIF(n,1,6) ) Histogram(dice, -0.5,5.5, 1); print(N) } BF=4.5; HF=3.5 N=10; REP(N) N=N*2; REP(N) N=N*2; REP(N) ...
![]()