# 2006 年 7 月 31 日作成 # じゃんけんの Simulation # 実験回数 rep=1000 res=rep(0,rep) # 何回勝負か match=100 for (i in 1:rep){ co=1 game=rep(0,match) while(co<=match){ a=sign(sin(pi*trunc(runif(1,0,1)*3)*(2/3)-pi*trunc(runif(1,0,1)*3)*(2/3))) if(abs(a)>0){game[co]=a;co=co+1} res[i]=sum(game) } } op<-par(mfrow=c(2,1)) hist(res) hist(res/rep)