I don't think this can be calculated in closed-form solution.
Function pWin(p As Double, nH As Long, nT As Long) As Variant
' Returns the probability that a coin with
' probability p of heads will accumulate
' nH excess heads before nT excess tails
Dim q As Double ' 1-p
Dim adPrb() As Double ' array of probabilities
Dim i As Long ' index to array
Dim pH As Double ' probability of Heads winning
Dim pT As Double ' probability of Tails winning
Dim dH As Double ' rate at which pH is increasing
Dim dT As Double ' rate at which pT is increasing
Dim dPrb As Double ' temporary variable
Dim iOdd As Long ' odd/even roll
Dim nToss As Long ' tosses made
If nH < 1 Then Exit Function
If nT < 1 Then Exit Function
q = 1# - p
ReDim adPrb(-nT To nH)
adPrb(0) = 1#
' loop until the sum of probabilities is close to 1
Do While pH + pT < 0.99999
iOdd = (iOdd + 1) Mod 2
For i = -nT + ((nT + iOdd) And 1) To nH Step 2
dPrb = 0#
If i > 1 - nT Then dPrb = p * adPrb(i - 1)
If i < nH - 1 Then dPrb = q * adPrb(i + 1) + dPrb
adPrb(i) = dPrb
If i = -nT Then pT = pT + dPrb
If i = nH Then pH = pH + dPrb
Next i
nToss = nToss + 1
Loop
' scale result to 100%
pWin = Array(pH / (pH + pT), nToss)
End Function
For your example on the other board (with a coin biased to flip heads 65% of the time, what's the probability of accumulating 7 heads before 9 tails?),
=pWin(65%, 7, 9) returns 99.62%.
Bookmarks