POV-Ray : Newsgroups : povray.off-topic : Coin game Server Time
6 Sep 2024 15:20:14 EDT (-0400)
  Coin game (Message 11 to 20 of 29)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 9 Messages >>>
From: scott
Subject: Re: Coin game
Date: 8 Jan 2009 11:19:21
Message: <49662789$1@news.povray.org>
>> I simulated this game in C++ and after 1e6 goes the average win-per-go 
>> settles down quite nicely to $8.09 and stays there up to 1e8 goes.
> 
>  How did you implement it? What type of integers did you use to count the
> amount of money? (Note that a 32-bit integer will overflow after only 32
> tosses of the coin, which is perfectly within the realm of possibility.)

I used 32bit and then 64bit integers, but the result was the same.


Post a reply to this message

From: scott
Subject: Re: Coin game
Date: 8 Jan 2009 11:27:37
Message: <49662979$1@news.povray.org>
>> How much should you be willing to pay for each go?
>
> Infinite. Sum(n,0,inf)( (1/2)^n * 2^(n-1) ) = sum(n,0,inf)(1/2) = inf.
>
> Of course it only makes sense to play if both you and the casino have
> infinite time and infinite money.

What if you don't have infinite time?

>> Does it depend on how many goes you are going to have?
>
> No, each round of game is independent, is it not?

Yes, but somehow you have to calculate the "realistic" amount that you will 
win in finite time, so you can decide how much you are willing to pay for 
this game.

If I offered you a go for $2 would you take it? How about $5, $10, $100 ? 
There is a stark contrast to these values and the theoretical infinite 
average expected winnings.


Post a reply to this message

From: Warp
Subject: Re: Coin game
Date: 8 Jan 2009 11:28:02
Message: <49662992@news.povray.org>
scott <sco### [at] scottcom> wrote:
> >> I simulated this game in C++ and after 1e6 goes the average win-per-go 
> >> settles down quite nicely to $8.09 and stays there up to 1e8 goes.
> > 
> >  How did you implement it? What type of integers did you use to count the
> > amount of money? (Note that a 32-bit integer will overflow after only 32
> > tosses of the coin, which is perfectly within the realm of possibility.)

> I used 32bit and then 64bit integers, but the result was the same.

  Did you at least put an assert() to check that no more than 31 (or 63)
tosses were ever made?

-- 
                                                          - Warp


Post a reply to this message

From: somebody
Subject: Re: Coin game
Date: 8 Jan 2009 11:47:44
Message: <49662e30@news.povray.org>
"scott" <sco### [at] scottcom> wrote in message
news:49662979$1@news.povray.org...

> > Of course it only makes sense to play if both you and the casino have
> > infinite time and infinite money.

> What if you don't have infinite time?

Then we decide on a cutoff.

> >> Does it depend on how many goes you are going to have?

> > No, each round of game is independent, is it not?

> Yes, but somehow you have to calculate the "realistic" amount that you
will
> win in finite time, so you can decide how much you are willing to pay for
> this game.

Sure, if you tell me exactly what the finite time is.

> If I offered you a go for $2 would you take it?

It's an even game for 4 throws, favours me for higher. You must show me that
you have $8.

> How about $5,

It's an even game for 10 throws, favours me for higher. You must show me
that you have $512.

> $10,

It's an even game for 20 throws, favours me for higher. You must show me
that you have $524,288.

This is on par with typical lotteries. Odds of winning the biggest jackpot
is almost one in a million, with more probable smaller prizes.

> $100 ?


It's an even game for 200 throws, favours me for higher. You must show me
that you have over $8e59.

Even then, I don't think I'd play, as I don't know where I'd put that money
if I win.

> There is a stark contrast to these values and the theoretical infinite
> average expected winnings.

The progression on maximum winnings possible might be a clue why.


Post a reply to this message

From: Kevin Wampler
Subject: Re: Coin game
Date: 8 Jan 2009 11:56:03
Message: <49663023$1@news.povray.org>
scott wrote:
> Here's an interesting puzzle.
> 
> A game is played by repeatedly tossing a coin until it lands heads.  If 
> it lands heads on the first try, you win $1 and the game is over.  If it 
> lands heads on the 2nd try, you win $2 and the game is over.  On the 3rd 
> try $4, and in general if you get the head on the nth try, you win 
> $2^(n-1).
> 
> I simulated this game in C++ and after 1e6 goes the average win-per-go 
> settles down quite nicely to $8.09 and stays there up to 1e8 goes.  Is 
> that correct?  How much should you be willing to pay for each go?  Does 
> it depend on how many goes you are going to have?

The expected payoff is infinite of course.  Personally, I'd pay about 
$10 to play the game, which indicates that I'm not attempting to 
maximize my expected payoff in making this decision.  The best I can 
formalize my reasoning is that the `utility' to me of winning a sum of 
money levels off asymptotically as that sum of money decreases.  For 
example, as far as I'm concerned there's no difference between winning 
$10^20 and $10^30, despite the fact that the latter is a vastly larger sum.

Furthermore, since I have only a very limited amount of money, losing $x 
has a higher negative utility than gaining $x -- as indicated by the 
fact that I wouldn't play a game with zero expected payoff (unless the 
game itself was fun of course).

To properly estimate how much I should pay to play under this view I 
should make a guess at my payoff vs. utility curve and then calculate an 
expected utility, but that's a bit more effort than I's probably care to 
spend were I presented with such a situation, so I'll take the 
satisficing approach and just say $10.

Also, I assume that you're familiar with the name of this puzzle, but on 
the off chance that you're not: 
http://en.wikipedia.org/wiki/St._Petersburg_paradox


Post a reply to this message

From: Warp
Subject: Re: Coin game
Date: 8 Jan 2009 12:10:30
Message: <49663386@news.povray.org>
I tried it myself with the program at the end of this post, and got a
bit different of a result. The program printed:

times tested: 100000000, sum: 1600092924, average: 16.0009
times tested: 200000000, sum: 2952473665, average: 14.7624
times tested: 300000000, sum: 4316535702, average: 14.3885
times tested: 400000000, sum: 6018669380, average: 15.0467
times tested: 500000000, sum: 7585216727, average: 15.1704
times tested: 600000000, sum: 8915924298, average: 14.8599
times tested: 700000000, sum: 10662688388, average: 15.2324
times tested: 800000000, sum: 12027713479, average: 15.0346
times tested: 900000000, sum: 13468996092, average: 14.9656
times tested: 1000000000, sum: 15300481793, average: 15.3005

  The program:

#include "IsaacRand.hh"
#include <iostream>
#include <cassert>

int main()
{
    typedef unsigned long long ULL;

    IsaacRand rng(0);

    ULL sum = 0;
    std::cout << "sizeof(sum) = " << sizeof(sum) << std::endl;

    ULL counter;
    for(counter = 0; counter < 1000000000ULL; ++counter)
    {
        ULL rounds = 0;
        while(rng.getNext() % 2 == 0)
        {
            ++rounds;
            assert(rounds < 64);
        }
        if(rounds) sum += 1ULL << rounds;
        else ++sum;

        if(counter % 100000000 == 100000000-1)
            std::cout << "times tested: " << counter+1
                      << ", sum: " << sum << ", average: "
                      << double(sum)/double(counter) << std::endl;
    }
}


Post a reply to this message

From: Darren New
Subject: Re: Coin game
Date: 8 Jan 2009 12:59:12
Message: <49663ef0$1@news.povray.org>
somebody wrote:
> Even then, I don't think I'd play, as I don't know where I'd put that money
> if I win.

I can help with that!

-- 
   Darren New, San Diego CA, USA (PST)
   Why is there a chainsaw in DOOM?
   There aren't any trees on Mars.


Post a reply to this message

From: somebody
Subject: Re: Coin game
Date: 8 Jan 2009 14:08:44
Message: <49664f3c$1@news.povray.org>
"Darren New" <dne### [at] sanrrcom> wrote in message
news:49663ef0$1@news.povray.org...
> somebody wrote:

> > Even then, I don't think I'd play, as I don't know where I'd put that
money
> > if I win.
>
> I can help with that!

Thanks, but I need help from a couple more people to stash away equivalent
of 40,000 universes' weight of money in 100 dollar bills.


Post a reply to this message

From: Warp
Subject: Re: Coin game
Date: 8 Jan 2009 15:14:22
Message: <49665e9e@news.povray.org>
Btw, this might be of interest:

http://en.wikipedia.org/wiki/St._Petersburg_paradox

-- 
                                                          - Warp


Post a reply to this message

From: scott
Subject: Re: Coin game
Date: 9 Jan 2009 02:50:36
Message: <496701cc$1@news.povray.org>
>> >  How did you implement it? What type of integers did you use to count 
>> > the
>> > amount of money? (Note that a 32-bit integer will overflow after only 
>> > 32
>> > tosses of the coin, which is perfectly within the realm of 
>> > possibility.)
>
>> I used 32bit and then 64bit integers, but the result was the same.
>
>  Did you at least put an assert() to check that no more than 31 (or 63)
> tosses were ever made?

It seems that the number of tosses never exceeds 16, even when running it 
1e9 times (where you would expect around 30 tosses is likely to come up).

OK I just fixed it now, I changed my head/tail generator from:

(rand()%2) == 0

to

rand() <= RAND_MAX/2

and now it seems to behave better, after 1e9 goes the maximum number of 
tosses in a row is 29, and the average winnings per go are around $14.30.

I guess that the RNG doesn't have more than 16 odd or even integers in a 
row, but it does has more than 16 either side of the mid-value.  Perhaps I 
need a better RNG to investigate further.


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 9 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.