看板 NCCU07_SOCIO 關於我們 聯絡資訊
這是我用SAS寫的 上半部是DATA RAND跑出1000組個亂數 下半部DATA homework是對獎 最後順便算一下賺賠多少這樣 不過現在這程式有小瑕疵我一直找不到真正的問題 就是我雖然做了檢驗的步驟可是有時候還是會跑出重複的數 我在猜測是不是因為小數點進位的問題,所以才會有那個x*很多個0出現 orz 給大家參考一下,也希望有高人可以指點一下阿~~ 題外話.....大樂透還真是有夠難中的 幾乎每次跑出來都是虧本,沒幾次有賺的.... 果然是十賭九輸阿... -------------------------------程式碼分隔線--------------------------------- DATA RAND; RETAIN SEED 12345678; DO I=1 TO 1000; X=RANUNI(SEED); Xn=X*10000000000000000; Xn=CEIL(Xn); N1=MOD(Xn,49)+1; X=RANUNI(SEED); Xn=X*10000000000000000; Xn=CEIL(Xn); N2=MOD(Xn,49)+1; if N1=N2=1 then N2=2; else N2=N2; if N2=N1 then N2=N2-1; else N2=N2; X=RANUNI(SEED); Xn=X*10000000000000000; Xn=CEIL(Xn); N3=MOD(Xn,49)+1; if N3=N2=1 then N3=2; else N3=N3; if N3=N2 then N3=N3-1; else N3=N3; if N3=N1=1 then N3=2; else N3=N3; if N3=N1 then N3=N3-1; else N3=N3; X=RANUNI(SEED); Xn=X*10000000000000000; Xn=CEIL(Xn); N4=MOD(Xn,49)+1; if N4=N3=1 then N4=2; else N4=N4; if N4=N3 then N4=N4-1; else N4=N4; if N4=N2=1 then N4=2; else N4=N4; if N4=N2 then N4=N4-1; else N4=N4; if N4=N1=1 then N4=2; else N4=N4; if N4=N1 then N4=N4-1; else N4=N4; X=RANUNI(SEED); Xn=X*10000000000000000; Xn=CEIL(Xn); N5=MOD(Xn,49)+1; if N5=N4=1 then N5=2; else N5=N5; if N5=N4 then N5=N5-1; else N5=N5; if N5=N3=1 then N5=2; else N5=N5; if N5=N3 then N5=N5-1; else N5=N5; if N5=N2=1 then N5=2; else N5=N5; if N5=N2 then N5=N5-1; else N5=N5; if N5=N1=1 then N5=2; else N5=N5; if N5=N1 then N5=N5-1; else N5=N5; X=RANUNI(SEED); Xn=X*10000000000000000; Xn=CEIL(Xn); N6=MOD(Xn,49)+1; if N6=N5=1 then N6=2; else N6=N6; if N6=N5 then N6=N6-1; else N6=N6; if N6=N4=1 then N6=2; else N6=N6; if N6=N4 then N6=N6-1; else N6=N6; if N6=N3=1 then N6=2; else N6=N6; if N6=N3 then N6=N6-1; else N6=N6; if N6=N2=1 then N6=2; else N6=N6; if N6=N2 then N6=N6-1; else N6=N6; if N6=N1=1 then N6=2; else N6=N6; if N6=N1 then N6=N6-1; else N6=N6; OUTPUT; END; PROC PRINT; VAR N1 N2 N3 N4 N5 N6; RUN; data homework; set RAND (KEEP=N1 N2 N3 N4 N5 N6); if N1=1then d11=1; else d11=0; if N1=16then d12=1; else d12=0; if N1=24then d13=1; else d13=0; if N1=31then d14=1; else d14=0; if N1=35then d15=1; else d15=0; if N1=39then d16=1; else d16=0; if N1=21 then dx=1; else dx=0; if N2=1then d21=1; else d21=0; if N2=16then d22=1; else d22=0; if N2=24then d23=1; else d23=0; if N2=31then d24=1; else d24=0; if N2=35then d25=1; else d25=0; if N2=39then d26=1; else d26=0; if N2=21 then dx=1; else dx=0; if N3=1then d31=1; else d31=0; if N3=16then d32=1; else d32=0; if N3=24then d33=1; else d33=0; if N3=31then d34=1; else d34=0; if N3=35then d35=1; else d35=0; if N3=39then d36=1; else d36=0; if N3=21 then dx=1; else dx=0; if N4=1then d41=1; else d41=0; if N4=16then d42=1; else d42=0; if N4=24then d43=1; else d43=0; if N4=31then d44=1; else d44=0; if N4=35then d45=1; else d45=0; if N4=39then d46=1; else d46=0; if N4=21 then dx=1; else dx=0; if N5=1then d51=1; else d51=0; if N5=16then d52=1; else d52=0; if N5=24then d53=1; else d53=0; if N5=31then d54=1; else d54=0; if N5=35then d55=1; else d55=0; if N5=39then d56=1; else d56=0; if N5=21 then dx=1; else dx=0; if N6=1then d61=1; else d61=0; if N6=16then d62=1; else d62=0; if N6=24then d63=1; else d63=0; if N6=31then d64=1; else d64=0; if N6=35then d65=1; else d65=0; if N6=39then d66=1; else d66=0; if N6=21 then dx=1; else dx=0; dS=d11+d12+d13+d14+d15+d16+ d21+d22+d23+d24+d25+d26+ d31+d32+d33+d34+d35+d36+ d41+d42+d43+d44+d45+d46+ d51+d52+d53+d54+d55+d56+ d61+d62+d63+d64+d65+d66; if dS=3 then D3=1; else D3=0; if dS=4 then D4=1; else D4=0; if dS=5 then D5=1; else D5=0; if dS=6 then D6=1; else D6=0; if dS+dx=4 then X3=1; else X3=0; if dS+dx=5 then X4=1; else X4=0; if dS+dx=6 then X5=1; else X5=0; S1=D3*400+D4*3869+D5*67491+D6*145669099+X3*1000+X4*18747+X5*3543292; S2=S1-50; proc print; VAR N1 N2 N3 N4 N5 N6 dS D3 D4 D5 D6 X3 X4 X5 ; SUM D3 D4 D5 D6 X3 X4 X5 S1 S2; run; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.229.24.163
kenshin528:SAS 指令好方便阿...SPSS的指令我覺得很難用... 09/25 13:12
kenshin528:你看獲得獎金要不要用你這邊的人數+上本次中獎人數 09/25 13:52
kenshin528:再除以獎金總額的方式來分配 09/25 13:53
FFWillie:我是覺得那是小事,目前是重複的數無法篩出來比較嚴重 09/25 21:58