> | P:=evalf(Matrix([[0,18/20,2/20],[18/20,0,2/20],[1/2,1/2,0]]));
Covert2R:=proc(x) local A; if x=1 then A:=R fi; if x=2 then A:=B fi; if x=3 then A:=G fi; evalf(A); end: |
> | RusRoul:=proc(X)
local N; if X=R then N:=Covert2R(stats[random,empirical[P[1,1],P[1,2],P[1,3]]](1)); fi; if X=B then N:=Covert2R(stats[random,empirical[P[2,1],P[2,2],P[2,3]]](1)); fi; if X=G then N:=Covert2R(stats[random,empirical[P[3,1],P[3,2],P[3,3]]](1)); fi; N; end: |
> | ManyRR:=proc(N)
local i,H; H:=[Covert2R(stats[random,empirical[18/38,18/38,2/38]](1))]; for i from 1 to N-1 do H:=[op(H),RusRoul(H[i])]; od; H; end: CountG:=proc(H) local C,i; C:=0; for i from 1 to nops(H) do if H[i]=G then C:=C+1; fi; od; evalf(C/nops(H)); end: |
> | M:=ManyRR(10000):
CountG(M); |
> |