mynum[luckynumbers__,n_]:=Block[{simulation,myresult},
(* 產稱n組中講號碼 *)
simulation=RandomSample[Range[49],6]&/@Range[n];
(* 把幸運號碼在n次中獎樣本裡面比對 *)
myresult=ParallelTable[Length@Flatten[Position[simulation[[z]],#]&/@
luckynumbers],{z,n}];
(* 輸出中獎機率 *)
{#[[1]],#[[2]]/n}&/@SortBy[N@Tally@myresult,First]
]
(* 隨便一組號碼連買20000期 *)
mynum[RandomSample[Range[49],6],20000]
(* {1,2,3,4,5,6} 連買20000期 *)
mynum[{1, 2, 3, 4, 5, 6}, 20000]
Mathematica 教學:樂秀程式
由 戴忠淵 於 2015年12月14日星期一
下午5:43 發表

讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~