Thread Rating:

ThatDonGuy
ThatDonGuy
  • Threads: 117
  • Posts: 6268
Joined: Jun 22, 2011
June 14th, 2017 at 1:41:33 PM permalink
With the talk of streaks going on here, it looks like it's time for another math lesson:

Given an event with probability p, where 0 < p < 1, the probability that a series of events has S consecutive successes before F consecutive failures is:

pS-1 (1 - qF) / (pS-1 + qF-1 - pS-1 qF-1)
where q = 1 - p


Let q = 1 - p; note 0 < q < 1

Let P(a, b) be the probability of having S consecutive successes before F consecutive failures from the current state of a consecutive successes and b consecutive failures
Note that at least one of a and b = 0 (you can't have current consecutive successes and consecutive failures at the same time).

P(S, 0) = 1
P(S-1, 0) = p P(S, 0) + q P(0, 1) = p + q P(0, 1)
P(S-2, 0) = p P(S-1, 0) + q P(0, 1) = p (p + q P(0, 1)) + q P(0, 1)
= p2 + P(0, 1) (q + pq)
...
P(S-n, 0) = pn + P(0, 1) q (1 + p + ... + pn-1)
...
P(1, 0) = P(S-(S-1), 0) = pS-1 + P(0, 1) q (1 + p + ... + pS-2)
= pS-1 + P(0, 1) q (1 - pS-1) / (1 - p)
= pS-1 + P(0, 1) q (1 - pS-1) / q
= pS-1 + (1 - pS-1) P(0, 1)

P(0, F) = 0
P(0, F-1) = p P(1, 0) + q P(0, F) = p P(1, 0)
P(0, F-2) = p P(1, 0) + q P(0, F-1)
= p P(1, 0) + q p P(1, 0)
= p (1 + q) P(1, 0)
P(0, F-3) = p P(1, 0) + q P(0, F-2)
= p (1 + q + q2) P(1, 0)
...
P(0, F-n) = p (1 + q + q2 + ... + qn-1) P(1, 0)
...
P(0, 1) = P(0, F-(F-1)) = p (1 + q + q2 + ... + qF-2) P(1, 0)
= p (1 - qF-1) / (1 - q) P(1, 0)
= p (1 - qF-1) / p P(1, 0)
= (1 - qF-1) P(1, 0)

P(0, 1) = (1 - qF-1) P(1, 0)
= (1 - qF-1) (pS-1 + (1 - pS-1) P(0, 1))
= (1 - qF-1) pS-1 + (1 - qF-1) (1 - pS-1) P(0, 1)
= (1 - qF-1) pS-1 + (1 - qF-1 - pS-1 + pS-1 qF-1) P(0, 1)

P(0, 1) * (1 - (1 - qF-1 - pS-1 + pS-1 qF-1) = (1 - qF-1) pS-1
P(0, 1) * (pS-1 + qF-1 - pS-1 qF-1) = (1 - qF-1) pS-1
P(0, 1) = (1 - qF-1) pS-1 / (pS-1 + qF-1 - pS-1 qF-1)

P(0, 0) = p P(1, 0) + q P(0, 1)
= p (pS-1 + (1 - pS-1) P(0, 1)) + q P(0, 1)
= pS + p (1 - pS-1 P(0, 1) + q P(0, 1)
= pS + (q + p - pS) P(0, 1)
= pS + (1 - pS) (1 - qF-1) pS-1 / (pS-1 + qF-1 - pS-1 qF-1)
= pS + pS-1 (1 - pS) (1 - qF-1) / (pS-1 + qF-1 - pS-1 qF-1)
= pS + (pS-1 - p2S-1) (1 - qF-1) / (pS-1 + qF-1 - pS-1 qF-1)
= pS + (pS-1 - pS-1 qF-1 - p2S-1 + p2S-1 q(F-1)) / (pS-1 + qF-1 - pS-1 qF-1)
= (p2S-1 + pS qF-1 - p2S-1 qF-1 + pS-1 - pS-1 qF-1 - p2S-1 + p2S-1 q(F-1)) / (pS-1 + qF-1 - pS-1 qF-1)
= ((p - 1) pS-1 qF-1 + pS-1) / (pS-1 + qF-1 - pS-1 qF-1)
= (pS-1 - (1 - p) pS-1 qF-1) / (pS-1 + qF-1 - pS-1 qF-1)
= pS-1 (1 - qF) / (pS-1 + qF-1 - pS-1 qF-1)


As always, peer review is welcomed and even encouraged.

If p = q = 1/2, S = 5, and F = 2:
Probability = pS-1 (1 - qF) / (pS-1 + qF-1 - pS-1 qF-1)
= 1/16 * 3/4 / (1/16 + 1/2 - 1/32)
= 3/34

If p = 1/3, q = 2/3, S = 2, and F = 5:
Probability = pS-1 (1 - qF) / (pS-1 + qF-1 - pS-1 qF-1)
= 1/3 * 211/243 / (1/3 + 16/81 - 16/243)
= 211/339
Last edited by: ThatDonGuy on Jun 14, 2017
mustangsally
mustangsally
  • Threads: 25
  • Posts: 2463
Joined: Mar 29, 2011
June 14th, 2017 at 3:52:12 PM permalink
application...
poker chip game my hubby plays

3 green chips and
6 red chips
in a bag

reach in grab one chip, note color, return chip, shake, repeat

if green gets 2 in a row B4 red gets 4 in a row
green wins

red wins with 4 in a row B4 2 greens in a row

game plays real even
(most that choose red think they can win lots)
fun with real or play $$$
*****
thanks for the formula and sharing
(I know I've seen it B4)

btw,
more challenging when # of trials is limited
have not done that one yet (only simulated)

Sally
I Heart Vi Hart
  • Jump to: