Google Answers Logo
View Question
 
Q: Calculation of statistical probability needed for this mathematical scenario ( Answered,   2 Comments )
Question  
Subject: Calculation of statistical probability needed for this mathematical scenario
Category: Science > Math
Asked by: billybee-ga
List Price: $25.00
Posted: 29 Nov 2006 23:22 PST
Expires: 29 Dec 2006 23:22 PST
Question ID: 786896
I'd like to know the probability of winning a particular betting
progression that utilizes the "parlay bet".  A parlay bet is when you
let all your winnings ride on the very next bet.

Example: You bet $5 on a coin toss of heads.  The coin toss is heads,
which means you win $5.  Your very next bet is $10 because you are
parlaying ("let it ride") your $5 in winnings from the first bet.  And
let's say you win that next bet and so now you win an additional $10. 
Your total winnings are now at $15.

That's an example of winning a parlay.  Here is an example of losing a
parlayed bet:

--I bet $5 on heads and the coin toss is heads.  I win $5 and let it
ride (parlay) on the next bet.  This means my second bet is $10.  And
let's say I lose that second bet because I guessed heads and the coin
toss came up tails.  I lose the $10 bet and now my total win/loss
total is minus-$5.

Okay, so here is the scenario for which I would like a statistical
probability calculated . . .

Let's say I am betting on heads or tails and that I have nine $5 chips
at my disposal.  In other words, I have nine levels of betting, as I
plan to only bet one chip per level.  One chip for each bet.

And let's say that each time I win a bet, I let my winnings ride on
the very next bet.  In other words, I parlay my winnings for the
second bet after any win.

Now let's say that once I win two bets in a row, the game is over and
I am declared a winner because I won two bets in a row without going
through my nine individual bets of $5 each.

On the other hand, if I go through all nine levels (all nine
individual $5 bets) without winning two in a row, I am declared a
loser and the game is over.

Can you calculate the odds for me on winning or losing this series of bets?

My question is, what is the statistical probability of me being able
to guess right twice in a row before being wrong through nine levels
of betting?

Let me explain further to make this crystal clear.

Obviously, I could win my wager if I guessed right the first two
times.  That would be a win on my first level (my first $5 chip).

Likewise, I could lose my wager if I guessed wrong nine times in a
row.  That would mean I lost at all nine levels.

However, the game could go on for more than just two tosses or nine
tosses --- I could be right nine different times thoughout the
progression and then be wrong on the very next guess, which means I
have not won because I was not able to guess right TWO times in a row.
 I could actually win nine individual bets throughout the betting
progression but still be declared a loser if I failed to win the
ensuing bet after each one of those wins.

Make sense?

Here is an example of failing to win at least two bets in a row at the
nine different levels with some individual wins mixed in  Keep in mind
that each "Level" represents a single $5 chip:

LEVEL 1: I guess heads and the coin toss is tails.  I lose my first $5
chip.  I now must bet my second $5 chip.

LEVEL 2: With my second $5 chip, I guess heads and the coin toss is
heads.  I win one in a row.  Now I let it ride for my next bet.

LEVEL 2. I guess heads and the coin toss is tails.  I lose my parlayed
bet and I must bet my third $5 chip.

LEVEL 3. With my third $5 chip, I guess tails and the coin toss is
tails.  I win one in a row and parlay my next bet.

LEVEL 3. With my parlayed bet, I guess tails and the coin toss is
heads.  I lose my parlayed bet and I must bet my fourth $5 chip.

LEVEL 4. With my fourth $5 chip, I guess heads and the coin toss is
tails.  I lose my fourth $5 chip and must bet my fifth $5 chip.

LEVEL 5. With my fifth $5 chip, I guess tails and the coin toss is
heads.  I lose my fiffth $5 chip and must bet my sixth $5 chip.

LEVEL 6. With my sixth $5 chip, I guess tails and the coin toss is
tails.  I win one in a row and parlay my next bet.

LEVEL 6. With my parlayed bet, I guess tails and the coin toss is
heads.  I lose my parlayed bet and must now bet my seventh $5 chip.

LEVEL 7. With my seventh $5 chip, I guess heads and the coin toss is
tails.  I lose my seventh $5 chip and must bet my eighth $5 chip.

LEVEL 8.  With my eighth $5 chip, I guess heads and the coin toss is
tails.  I lose my eighth $5 chip and must bet my ninth $5 chip.

LEVEL 9.  With my ninth and final chip, I guess tails and the coin
toss is tails.  I win one in a row and parlay my next bet.

LEVEL 9.  With my parlayed bet, I guess tails and the coin toss is
heads.  I lose my parlayed bet and since I have used all nine of my $5
chips, the game is over and I am declared a loser.

So my question is, is there any way to calculate what my odds are of
failing to win at least one parlayed bet on a 50-50 coin toss when you
have nine individual chances to do so?  Mind you, I won't always get
nine chances at a parlayed bet.  As you can see from the above
example, I won some bets throughout the game but never failed to win
two in a row.

The game could be over in as few as three decisions (I win all three
bets), or it could last for as long as 18 decisions (won the first bet
but then lost all nine parlayed bets).  It could also last any length
in between.

So to summarize my question --- what is the precise statistical
probability of winning or losing the game as described above?  Please
note I am looking for exact statistical odds, not a guess!  And please
note I am looking for the exact odds that take into account ALL
possibilities that exist in this game.

I will gladly pay anyone who can answer this correctly and precisely. 
(If it's possible, and I don't know that it is.)

If calculating the odds for the described scenario is NOT
mathematically possible, then I'm not willing to pay to find that out,
but if there IS an answer, I'll be happy to pay and add a nice tip!

Thanks in advance . . .
Answer  
Subject: Re: Calculation of statistical probability needed for this mathematical scenario
Answered By: leapinglizard-ga on 30 Nov 2006 19:46 PST
 
Dear billybee,


The easiest way to calculate the odds you seek is by direct
simulation. In other words, one writes a program that works out every
possible outcome of the game, tallying wins and losses along the way.

Because you have a 50% chance of winning each time you make a bet, it
is not necessary to keep track of whether the coin toss results in
heads or tails. The program need only remember whether you won or lost
the bet.

The following is a Python program that simulates your game up to a
maximum of nine tosses, printing a textual representation of each
outcome.


#===begin parlay.py

class Parlay:
    def __init__(self, max_len):
        self.wins = 0
        self.losses = 0
        self.max_len = max_len

    def go(self, record):
        if len(record) == self.max_len:
            self.losses += 1
            print record + ' : loss'
            return
        if len(record) == 0:
            self.go('w')
            self.go('L')
            return
        self.go(record+'L')
        if record[-1] == 'w':
            self.wins += 1
            print record + 'w : win'
        else:
            self.go(record+'w')

test = Parlay(9)
test.go('')

print
print 'number of losses = %d' % (test.losses,)
print 'number of wins = %d' % (test.wins,)

print
odds = 100.0 * test.wins / (test.losses + test.wins)
print 'odds of losing = %.02f%%' % (100.0 - odds,)
print 'odds of winning = %.02f%%' % (odds,)

#===end parlay.py


You can download the Python scripting environment from

http://www.python.org/download/

to run the script yourself, or you can just look at the transcript
I've posted at the following address.

http://plg.uwaterloo.ca/~mlaszlo/answers/parlay.9.txt


If you have Python, you can easily change the length of the game to
compute different odds. For your convenience, here are the odds of
winning games of maximum length 2 through 9, inclusive.


2:  25.00%
3:  28.57%
4:  33.33%
5:  35.00%
6:  36.36%
7:  37.04%
8:  37.50%
9:  37.76%


Regards,

leapinglizard

Clarification of Answer by leapinglizard-ga on 01 Dec 2006 04:12 PST
There is a flaw in my reasoning. Not every outcome computed by the
program is equally likely, since the game is likelier to end sooner
rather than later. In fact, as we increase the maximum number of coin
tosses, the probability of winning converges on 100%. By running ten
million trials, I have found that the chance of winning within nine
tosses is about 82.6%, but I know that you want an exact answer. I
shall post an analytical solution later.

leapinglizard

Clarification of Answer by leapinglizard-ga on 01 Dec 2006 13:20 PST
My original simulation was incorrect because I failed to see that
the chance of compiling a specific winning record depends on its
length. Before considering the odds of winning within nine tosses,
let us consider shorter versions of the game.


The probability of winning the game in just two tosses is .25 (or 25%),
since the winning record "ww" is one of 2*2 = 4 possible sequences of
two tosses. These four sequences are listed below, with a plus symbol
next to the winning record.

    LL
    Lw
    wL
    ww +


If we extend the game to three tosses, there are 2*2*2 = 2^3 = 8 possible
sequences, two of which are actually won before the final toss. These
are marked with an asterisk in the following list.

    LLL
    LLw
    LwL
    Lww +
    wLL
    wLw 
    wwL *
    www *

There is only one sequence, "Lww", that requires the third toss to
win. It has a probability of one in eight, 1/8 = .125, which means that
the total chance of winning the game in three tosses or fewer is

    .25 + .125  =  .375 . 


There are 2^4 = 16 sequences of four tosses, each with a 1/16 = .0625
probability. Two of these, "wLww" and "LLww", are won only on the final
toss, so the chance of winning in four tosses or fewer is

    .375 + 2*.0625  =  .5 .


By extending the game to five tosses, we add three more sequences, namely
"wLLww", "LLLww", and "LwLww", that are only won on the final toss. Each
has a chance of 1/2^5 = 1/32 = .03125, so the cumulative odds are

    .5 + 3*.03125  =  .59375 .

    
Extending the game to six tosses adds five more sequences -- "wLLLww",
"wLwLww", "LLLLww", "LLwLww", "LwLLww" -- each with a chance of 1/64 =
.015625 .

    .59375 + 5*.015625  =  .671875 .


The seventh toss gives us eight more ways to win.

    wLLLLw
    wLLwLw 
    wLwLLw
    LLLLLw 
    LLLwLw
    LLwLLw
    LwLLLw
    LwLwLw

    .671875 + 8*.0078125  =  .734375 .


The eighth gives us 13 more, which I shall not list here.

    .734375 + 13*.00390625  =  .78515625 .


The ninth and final toss yields 21 more ways to win.

    .78515625 + 21*.001953125  =  0.826171875 .


The chance of winning the game within nine tosses is therefore exactly
82.6171875%.


The following Python script displays the longest winning records possible
with a given number of coin tosses.


#===begin parlay.analytical.decimal.py

import sys

class Parlay:
    def __init__(self, max_len):
        self.wins = 0.0
        self.extras = 0
        self.max_len = max_len

    def go(self, record):
        if len(record) == self.max_len:
            return
        if len(record) == 0:
            self.go('w')
            self.go('L')
            return
        self.go(record+'L')
        if record[-1] == 'w':
            self.wins += .5**(len(record)+1)
            if len(record) == self.max_len-1:
                self.extras += 1
                print self.extras, record
        else:
            self.go(record+'w')

if len(sys.argv) > 1:
    test = Parlay(int(sys.argv[1]))
else:
    test = Parlay(9)
test.go('')

print 'chance of winning within %d tosses =' % test.max_len, test.wins

#===end parlay.analytical.decimal.py


It is unnecessary to employ such a program if we observe that the number
of additional winning records introduced by each game increment follows
the Fibonacci sequence. Each term of this sequence is equal to the sum
of the two previous terms.

Wikipedia: Fibonacci number
http://en.wikipedia.org/wiki/Fibonacci_number


To obtain the odds of winning the game within n tosses, therefore,
it should suffice to compute the sum of

    F(i-1) * 1/2^i

for all i from 1 to n, inclusive.

I cannot yet prove this, but I believe it to be true.


The following script implements this formula.


#===begin parlay.fibonacci.py

import sys 

if len(sys.argv) > 1:
    n = int(sys.argv[1])
else:
    n = 9

fib_prev, fib_curr = 0, 1
sum = 0.0 
for i in range(2, n+1):
    sum += fib_curr * .5**i
    fib_next = fib_prev + fib_curr
    fib_prev = fib_curr
    fib_curr = fib_next

print 'chance of winning within %d tosses =' % n, sum

#===end parlay.fibonacci.py


Finally, for those who are skeptical of my analysis, I offer a script
that simulates the game in batches of 100,000 trials while tallying a
cumulative win percentage.

Regards,

leapinglizard


#===begin parlay.simulation.chars.recursive.py

import sys, random, time

class Parlay:
    def __init__(self, max_tosses):
        self.wins = 0
        self.losses = 0
        self.max_tosses = max_tosses

    def go(self, previous='', tosses=0):
        if tosses == self.max_tosses:
            self.losses += 1
            return
        outcome = 'Lw'[random.randrange(2)]
        if tosses == 0:
            self.go(outcome, 1)
        elif outcome == 'L':
            self.go('L', tosses+1)
        elif previous == 'w':
            self.wins += 1
        else:
            self.go('w', tosses+1)

if len(sys.argv) > 1:
    test = Parlay(int(sys.argv[1]))
else:
    test = Parlay(9)
run_start = time.time()
i = 0
while 1:
    i += 1
    lap_start = time.time()
    for j in range(10**5):
        test.go()
    print
    print 'lap time = %.02fs' % (time.time() - lap_start)
    print 'total time = %.02fs' % (time.time() - run_start)
    print 'number of trials = %d' % (i*j+i,)
    odds = 100.0 * test.wins / (test.losses + test.wins)
    print 'odds of winning = %.04f%%' % (odds,)

#===end parlay.simulation.chars.recursive.py
Comments  
Subject: Re: Calculation of statistical probability needed for this mathematical scenario
From: mike__d-ga on 29 Nov 2006 23:58 PST
 
On each coin toss you have a .5 probability of guessing the correct
outcome, so the probability of you guessing two in a row is .5 * .5 =
.25

.25 times the number of levels of betting (9) will give you 2.25, so
you should win your parlay bet 2.25 times out of the 9 times that you
play the game.

If you win the parley bet then your net winnings (with a probability
of .25) will be $15. If you lose either of the bets (with a
probability of .75) then your net loss will be -$5.

SO: If you multiply the number of times you should win (2.25) by the
net winnings of $15 you get $33.75. If you multiply the number of
times you lose ( 9 - 2.25 = 6.75) by the net loss of -$5 then you
should lose $33.75.

By subtracting your expected winnings from the expected losses you should net $0.


Statistically you should break even.
Subject: Re: Calculation of statistical probability needed for this mathematical scenario
From: jacobl-ga on 30 Nov 2006 00:08 PST
 
I think you've overcomplicated the problem in your own mind. The
answer is actually fairly simple.

The probability of failing to win at least one parlayed bet is the
same as that of losing each round of betting. The probability of
losing any one round is 3/4 (equivalently, the chance of winning any
one round is 1/4). The probability of losing 9 rounds in a row is
therefore (3/4)^9 = (3/4)*(3/4)*(3/4)*(3/4)*(3/4)*(3/4)*(3/4)*(3/4)*(3/4)
= 19683/262144 = 0.0751.

Written as odds, that would be 12.32:1

That's definitely not worth $25 and I'm only here because I heard the
site is closing so don't worry about any payment!

Jacob

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy