Tossing a coin 3 times: Is it a fair game?

  • Thread starter Thread starter humanino
  • Start date Start date
  • #31
All right...
Code:
#define HEAD 1
#define TAIL 0

int toss1, toss2, toss3;
int Nicolas, Henry;
int LNicolas, LHenry; 
int BNicolas, BHenry; 

int nowinner(int Tosses) 
{
        if (!BNicolas && toss1 == HEAD && toss2 == TAIL && toss3 == TAIL)
        {       
                Nicolas++;
                LNicolas += Tosses; 
                BNicolas = 1;
                return 0;
        }       
        if (!BHenry && toss1 == HEAD && toss2 == TAIL && toss3 == HEAD)
        {       
                Henry++;
                LHenry += Tosses; 
                BHenry = 1;
                return 0;
        }       
        return 1;
}

int main(int argc, char* argv[]) 
{
        Nicolas = Henry = LNicolas = LHenry = 0;
        int Ngames=100000, Tosses; 

        for(int game=0;game<Ngames;game++)
        {       
                BNicolas=0;
                BHenry=0;
                toss1 = rand() % 2;
                toss2 = rand() % 2;
                toss3 = rand() % 2;
         
                Tosses = 3;

                /* while(!BNicolas&&!BHenry) */ /* will give 5 and 5 */
                while(!(BNicolas&&BHenry)) /* will give 8 and 10 */
                {       
                        nowinner(Tosses++);
                        toss1 = toss2;
                        toss2 = toss3;
                        toss3 = rand() % 2;
                }       
        }       
        printf("Probabilities to win : Nicolas=%2.6f Henry=%2.6f\n",float(Nicolas)/Ngames,float(Henry)/Ngames);
        printf("Number of tosses to victory : Nicolas=%2.6f/ Henry=%2.6f\n",float(LNicolas)/Nicolas,float(LHenry)/Henry);
        return 0;
}
 
Mathematics news on Phys.org
  • #32
Actually, it's so confusing... The original observation I had was "the average distance between both configurations in the limit of an infinitely long chain of tossing". I came up with the game, but that was plain wrong as I said. Sorry about that. I still think the observation is kind of interesting :rolleyes:
 
  • #33
humanino said:
for each game, you toss until you have found both configurations. "stop" counts how many configurations have been found for each game.

Why do you look for the second? First configuration found, game over.
 
  • #34
Borek said:
Why do you look for the second? First configuration found, game over.
I see that. As I said, it works in an infinite chain of tosses, as the average number of tosses between configurations. I did that as well, it gives the same results as searching for the second. The difference is in between the number of tosses until the configuration ignoring the other configuration.

Once again, the original game description simply does not work.
 
  • #35
Attached are the distributions of the number of tosses, in the case of an infinite chain (or if you keep tossing after having found the first one), and in the case where you stop tossing as soon as you found one of the two.
 

Attachments

  • avg_inf.gif
    avg_inf.gif
    9.4 KB · Views: 342
  • avg_till_firg.gif
    avg_till_firg.gif
    8.8 KB · Views: 472
  • #36
From what I gather, the original problem should have specified that each player tosses his own coin.
 
  • #37
Incidentally, it's not difficult to work these things out algebraically with matrix arithmetic.

For example, if your question is "how long before you get HTH?", you can solve it as follows.

There are four relevant states, determined by the last few flips of the coin
. TT
. HT
. TTH
. Victory
. HH

After three flips, the distribution on these states is given by the vector
<br /> v_3 = \left[ \begin{array}{c} 1/4 \\ 1/4 \\ 1/4 \\ 1/8 \\ 1/8 \end{array} \right]<br />

And after each individual flip, the transition matrix is
<br /> A = \left[ \begin{array}{ccccc}<br /> 1/2 &amp; 1/2 &amp; 0 &amp; 0 &amp; 0 \\<br /> 0 &amp; 0 &amp; 1/2 &amp; 0 &amp; 1/2 \\<br /> 1/2 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\<br /> 0 &amp; 1/2 &amp; 0 &amp; 1 &amp; 0 \\<br /> 0 &amp; 0 &amp; 1/2 &amp; 0 &amp; 1/2<br /> \end{array} \right]<br />
(e.g. the first column says that TT transitions to each of TTH and TT with probability 1/2)

The distribution on these states after n flips is given by
<br /> v_{n} = A^{n-3} v_{3}<br />

from which you can compute whatever you want. For example, the probability of not winning on or before the n-th flip is

<br /> \left[ \begin{array}{ccccc} 1 &amp; 1 &amp; 1 &amp; 0 &amp; 1 \end{array} \right] A^{n-3} v_3<br />

and the probability that you win on the n-th flip is (for n \geq 4):

<br /> (1/2) \left[ \begin{array}{ccccc} 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \end{array} \right] A^{n-4} v_3 \right]<br />


If you think about it more, I'm sure you can come up with a more economical selection of states. Maybe use a new symbol "S" for the starting state, so you can start the analysis at 0 flips instead of 3.
 
Last edited:
  • #38
Borek said:
Why do you look for the second? First configuration found, game over.
Looking for the second win (and by the other person) changes the problem significantly. The two players have an equal probability of winning. Moreover, the expected value of the number of tosses before a win is equal for the two players: five throws. Making it so that the coin tosses continue until a winning configuration is found for each player is a different problem.
 
  • #39
D H said:
Looking for the second win (and by the other person) changes the problem significantly. The two players have an equal probability of winning. Moreover, the expected value of the number of tosses before a win is equal for the two players: five throws. Making it so that the coin tosses continue until a winning configuration is found for each player is a different problem.

That's exactly what I was pointing at, humanino was just solving completely different question :smile:
 
  • #40
Borek said:
That's exactly what I was pointing at, humanino was just solving completely different question :smile:
I just thought initially there was something interesting going on. At this point, the problem has been explained by several methods, and I take the opportunity to thank Hurkyl for his contribution. I said several times that it was a pity I misstated the initial problem.
 
  • #41
Yes, definitely Hurkyl's post is very interesting. Sometimes selection of good formalism to describe the problem is half of the succes.
 
  • #42
The problem becomes more interesting if the choices are htt vs. ttt. The odds are not even close to 50/50.
 
  • #43
Redbelly98 said:
The problem becomes more interesting if the choices are htt vs. ttt. The odds are not even close to 50/50.
What do you get ?
87.5/12.5 ?
 
  • #44
Yes, 87.5/12.5 favoring htt.

The reason:

For ttt to win, it must win on the very 1st 3 coin tosses (1/8 chance of that). Otherwise, htt must happen before ttt. I.e., if ttt does not occur until after the 1st 3 tosses then it will be preceded by an "h", in which case htt wins.
 

Similar threads

  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 20 ·
Replies
20
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 57 ·
2
Replies
57
Views
6K
Replies
4
Views
3K
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K