看大家讨论红包问题那么热烈,本以为没什么讨论的,直觉是换不换也不提高中奖概率。确实,实践是检验真理的唯一标准啊。。。试了一百万次,结果大吃一斤!333251 vs 666100。
不换中奖次数为 333251
换了中奖次数为 666100
中奖机会几乎大了一倍!!!
如有兴趣,拷贝以下程序去自己机器的EXCEL做一个MACRO即可运行,无色无味无毒,如怕中毒就算了。。。哈哈哈。。。
Sub Macro1()
Dim ua As Integer ' pick stay
Dim ub As Integer ' pick change
Dim uw As Integer ' win pick
Dim uha As Integer ' host pick (no win)
Dim uhb As Integer ' host pick (no win)
Dim wa As Long ' case(no_change) win times
Dim wb As Long ' case(change) win times
Dim i As Long
Dim n As Long
wa = 0
wb = 0
n = 1000000
For i = 1 To n
ua = CInt(Int((3 * Rnd()) + 1))
ub = CInt(Int((3 * Rnd()) + 1))
uw = CInt(Int((3 * Rnd()) + 1))
uha = CInt(Int((3 * Rnd()) + 1))
uhb = CInt(Int((3 * Rnd()) + 1))
uha = hostPick(uha, ua, uw)
uhb = hostPick(uhb, ub, uw)
ub = changePick(ub, uhb)
wa = wa + winOrNot(ua, uw)
wb = wb + winOrNot(ub, uw)
Next
MsgBox "Win(Stay) = " & CStr(wa) & " " & " vs Win(Change) = " & CStr(wb) & " out of " & CStr(n) & " times try"
End Sub
Function hostPick(h, p, w) As Integer
While h = w Or h = p
h = CInt(Int((3 * Rnd()) + 1))
Wend
hostPick = h
End Function
Function changePick(p, h) As Integer
Dim c As Integer
c = CInt(Int((3 * Rnd()) + 1))
While c = p Or c = h
c = CInt(Int((3 * Rnd()) + 1))
Wend
changePick = c
End Function
Function winOrNot(p, w) As Integer
If p = w Then
winOrNot = 1
Else
winOrNot = 0
End If
End Function