• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

another die question

Conditional on the first toss being odd, either 1) the second toss is the same as the first (the 1/6 part) or 2) the second is an odd number different from the first toss (with probability 2/6=1/3) after which the sum starting with the second toss has to be odd (probability 1-q) or 3) the second is an even number (probability 1/2) after which the sum starting with the second toss is odd (probability 1-p)

also note that p+q is not 1.

The underlined above is actually incorrect! You forget that by this time you actually have two different odd rolls, whose sum is even, and it is the parity of the sum that matters here regardless of what the actual number are.
 
the truth is I didn't bother reading your post because I know it's wrong. i'll leave it to other people to confirm it to you that P(even) is in fact 47/82.

You are funny. Again you are reverberating with your classic fallacy. You hardly read people's posts even when they show where you went wrong.
 
Please stick with the subject at hand. Please do not evade the main issue. I have pinpointed EXACTLY where you went wrong with your solution. Please be a gentleman and take a look at what I said regarding your error.

oh yeah, i heard about you. you're that troll.

Conditional on the first toss being odd, either 1) the second toss is the same as the first (the 1/6 part) or 2) the second is an odd number different from the first toss (with probability 2/6=1/3) after which the sum starting with the second toss has to be odd (probability 1-q) or 3) the second is an even number (probability 1/2) after which the sum starting with the second toss is odd (probability 1-p)

also note that p+q is not 1.

The underlined above is actually incorrect! You forget that by this time you actually have two different odd rolls, whose sum is even, and it is the parity of the sum that matters here regardless of what the actual numbers are.
 
The underlined above is actually incorrect! You forget that by this time you actually have two different odd rolls, whose sum is even, and it is the parity of the sum that matters here regardless of what the actual number are.

Peter is correct. By the way, this is exactly where your reasoning fails (or your definition of p does not apply rather). Peter has defined his p and q carefully, so that his beautiful argument works out just right.
Quantyst, couple of comments on your behavior. I have followed some of your threads on this forum. Sometimes you post fantastic problems or solutions. I enjoy them and thank you for this. Given that, you need to learn some manners. You joined this thread and posted your solution (at least initially) without reading the reasoning and previous threads of other smart people who posted on it. Despite your sometimes poor attempts to be, you are not God-given. You need to learn to respect other people's math abilities, which could be just as good, worse, or even better than yours on some particular problems. So, could you stop attacking other people (and their solutions) in your posts, and take your offensive behavior elsewhere?
Finally, if you are still not convinced that your argument in question is wrong, try to do the same problem with Markov chains. Given your math abilities, it should be no problem to obtain an answer different from your initial one.
 
Dear Rados Radoicic,

Please stick with the subject matter at hand. I would rather finish one thing at a time rather than mix many unrelated things together in one post. If you want to do a thorough analysis of my exchanges with peterruse, I'd be glad to do it later. So, on to your claim that "Peter is correct".

Look at his second equation:

q=(1/6)+(1/3)*(1-q)+(1/2)*(1-p).

The quantity (1-q) in the equation is the probability of getting an odd sum given that the first number is odd. Imagine that you get two different odd numbers in the first and second rolls whose sum (which is really what matters) is even. Now you are back to a situation as if you are just about starting the game all over. So, from this point on, your probability of getting an even sum is p, not (1-q) as claimed by peterruse. Please think about this before you intervene. If you are still not convinced, please do a tree diagram. And finally, if you or someone else can do a simulation, that would be great, too.

(BTW: Please take a look at your post. You jump in and just say: "Peter is correct. By the way, this is exactly where your reasoning fails (or your definition of p does not apply rather). Peter has defined his p and q carefully, so that his beautiful argument works out just right." It is important to see that you have not at all addressed my reasoning as to why your so-called "his beautiful argument" is actually flawed. Instead you are speaking of my answer (which is not presently at issue here) being wrong, which is perhaps an unintended attempt on your part to evade my reasoning as to why peterruse's equation is wrong. So, what needs to be done NOW is to address my critique of peterruse's answer.)

Peter is correct. By the way, this is exactly where your reasoning fails (or your definition of p does not apply rather). Peter has defined his p and q carefully, so that his beautiful argument works out just right.
Quantyst, couple of comments on your behavior. I have followed some of your threads on this forum. Sometimes you post fantastic problems or solutions. I enjoy them and thank you for this. Given that, you need to learn some manners. You joined this thread and posted your solution (at least initially) without reading the reasoning and previous threads of other smart people who posted on it. Despite your sometimes poor attempts to be, you are not God-given. You need to learn to respect other people's math abilities, which could be just as good, worse, or even better than yours on some particular problems. So, could you stop attacking other people (and their solutions) in your posts, and take your offensive behavior elsewhere?
Finally, if you are still not convinced that your argument in question is wrong, try to do the same problem with Markov chains. Given your math abilities, it should be no problem to obtain an answer different from your initial one.
 
Look at his second equation:

q=(1/6)+(1/3)*(1-q)+(1/2)*(1-p).

The quantity (1-q) in the equation is the probability of getting an odd sum given that the first number is odd. Imagine that you get two different odd numbers in the first and second rolls whose sum (which is really what matters) is even. Now you are back to a situation as if you are just about starting the game all over. So, from this point on, your probability of getting an even sum is p, not (1-q) as claimed by peterruse. Please think about this before you intervene. If you are still not convinced, please do a tree diagram. And finally, if you or someone else can do a simulation, that would be great, too.
I will address your critique. You are wrong, he is right (Explanation below). I don't think you understand his logic. It wasn't easy for me to understand it, but I figured it out afterwards.

Let's look at his second equation.
q=(1/6)+(1/3)*(1-q)+(1/2)*(1-p).
I want to go with your case. you get 2 different odd numbers. Remember, every time you don;t end the problem you start all over again. So, once you get an odd sum (in your case, the first number is odd), to be able to get to even, you want the total of all new numbers to be odd. q is the probability of getting an even sum if the 1st number is odd. What we are looking for is to get an odd sum, so that after adding it to the first odd number, we end up with an even sum (ex: 1,3,5,5 or 1,3,1,1...). the probability we are looking for is to get an odd sum if the first number is odd, which is 1-q (but we are applying this to the second number which is an odd number different from the first).
p is the probability of getting an even sum if the first number is even. Same logic applies to the third term, if you understand the second, you will understand the third. Using P in the second term of q means that the "sum recorded so far" (in your case the first odd number) is even (check the definition of p).
Go over the whole thread, maybe you will understand it this time.
I will try to do a simulation of this in the next couple of days.
 
Dear AlexandreH,

Thank you for your response which I read completely. It is apparent, and I will show it to you if only you read and honestly try to understand my response, that you've missed the sequence of events here.

First off, let's begin with peterruse's last step when he writes: "(1/2)*(p+q)=(47/82)"

This suggests, as exactly what he means to say, that already one roll has taken place. On the first roll, either an even number comes up with probability (1/2) or an odd number comes up with probability (1/2). That's why he adds them up as (1/2)*(p+q). Now for the part q in the expression, on the first roll we already have an odd number behind us in the peterruse's second equation; namely,

q=(1/6)+(1/3)*(1-q)+(1/2)*(1-p). (****)

This equation means that we already have rolled the die once and have seen an odd number (say, X) come up as the first roll. Now, from this point on, either (i) the second roll is the same as X with probability (1/6), at which point we stop the game, or (ii) the second roll is odd but different from X with probability (1/3), or (iii) the second roll is even with probability (1/2).

In the case (ii) we already have behind us two different odd numbers for the first and second rolls, whose sum, of course, is even. So, in order to get an even sum for the WHOLE game, you should not get an odd sum for the remainder of the game after the case (ii), but you should get an even sum for the remainder of the game after the case (ii). To write (1-q) after (1/3) in the equation (****) means that peterruse is looking to get an odd sum after the first two odd-numbered rolls (whose sum is even). That's incorrect.

I hope this clears the fog.
 
In the case (ii) we already have behind us two different odd numbers for the first and second rolls, whose sum, of course, is even. So, in order to get an even sum for the WHOLE game, you should not get an odd sum for the remainder of the game after the case (ii), but you should get an even sum for the remainder of the game after the case (ii). To write (1-q) after (1/3) in the equation (****) means that peterruse is looking to get an odd sum after the first two rolls are different odd numbers. That's incorrect.

I hope this clears the fog.

That's where you're wrong.

Look carefully at how I've defined (q): It is the conditional probability that, given that the initial roll is odd, the sum of all rolls, including the initial roll, is even. The problem concerns itself with the sum of all rolls, not just the ones after the first roll. You are right that the sum of the rolls after the first two should be even if the first two are odd, but that's not what we're concerned with. We're concerned with the fact that the problem resets once the second roll is different from the first, so that the second roll is now treated as the initial roll and the sum starting with the second roll indeed must be odd because the first roll was odd.
 
Dear AlexandrH,

Thank you for your response which I read completely. It is apparent, and I will show it to you if only you read and honestly try to understand my response, that you've missed the sequence of events here.

First off, let's begin with peterruse's last step when he writes: "(1/2)*(p+q)=(47/82)"

This suggests, as exactly what he means to say, that already one roll has taken place. On the first roll, either an even number comes up with probability (1/2) or an odd number comes up with probability (1/2). That's why he adds them up as (1/2)*(p+q). Now for the part q in the expression, on the first roll we already have an odd number behind us in the second equation; namely,

q=(1/6)+(1/3)*(1-q)+(1/2)*(1-p). (****)

This equation means that we already have rolled the die once and have seen an odd number (say, X) come up as the first roll. Now, from this point on, either (i) the second roll is the same as X with probability (1/6), at which point we stop the game, or (ii) the second roll is odd but different from X with probability (1/3), or (iii) the second roll is even with probability (1/2).

In the case (ii) we already have behind us two different odd numbers for the first and second rolls, whose sum, of course, is even. So, in order to get an even sum for the WHOLE game, you should not get an odd sum for the remainder of the game after the case (ii), but you should get an even sum for the remainder of the game after the case (ii). To write (1-q) after (1/3) in the equation (****) means that peterruse is looking to get an odd sum after the first two rolls are different odd numbers. That's incorrect.

I hope this clears the fog.
Nop. Again. You are wrong. Try to understand what many people are trying to explain. Do everyone a favor and read from the start.
If I use your cases ((i) , (ii) and (iii)). We agree on the first one. Now for (ii), once the second number is odd but different than the first, we have a new game. This game has the second roll as Roll1 and the third roll as Roll2. In your case, you assumed that the third roll is Roll1 and the fourth one is Roll2 (Which is wrong). Now, if you understand the logic I am explaining you will see why we need an odd sum. only one roll is behind us if we don't have the first case (i) and the roll is odd, which means we need an odd sum.
Thank you.
 
I am puzzled as to how you are so certain of your attributions onto me when you write: "you [meaning I] assumed that the third roll is Roll1 and the fourth one is Roll2". I've done no such thing.

Let's be concrete about this. Suppose the first roll of the entire game is 5 and the second roll is 3. From this point on, in order that we get an even sum for the ENTIRE game, we need to look to probability of getting an even sum, not an odd sum, for the remainder of the game. So writing (1-q), which is the probability of getting an odd sum (with a certain initial condition) for the remainder of the game is wrong. Period.

You guys are remarkable! You have a monumental inertia in not being able to see the obvious.

Nop. Again. You are wrong. Try to understand what many people are trying to explain. Do everyone a favor and read from the start.
If I use your cases ((i) , (ii) and (iii)). We agree on the first one. Now for (ii), once the second number is odd but different than the first, we have a new game. This game has the second roll as Roll1 and the third roll as Roll2. In your case, you assumed that the third roll is Roll1 and the fourth one is Roll2 (Which is wrong). Now, if you understand the logic I am explaining you will see why we need an odd sum. only one roll is behind us if we don't have the first case (i) and the roll is odd, which means we need an odd sum.
Thank you.
 
Let's have two 'parallel' but uncommingled arguments going on, if you don't mind. So, please do not mingle this post (or SUB-THREAD) with the one we have been having so far. Let's call this sub-thread the quantyst's approach.

Would you please just tell me where I went wrong with my solution? Thank you.

Answer: Probability of Sum being Even is 4/7 and Probability of Sum Being Odd is 3/7.

Here's why:

Let p denote the probability of the sum being even when the game stops.

Upon the first throw, we have Case (O) an odd roll with probability 1/2, and Case (E) an even roll with probability 1/2.

Under Case (O), we have three subsequent cases:

Case (O-SO) where the second roll is the same as first (odd and the same) with probability 1/6, at which point the process ends with an even sum. So, we reach this ending point with a net probability of (1/2)*(1/6)=1/12.

Case (O-DO) where the second roll is different but odd with probability 2/6, from which point onwards the probability of getting an even sum when the process ends is p as the first two rolls, both being odd, have an even sum. Thus, the net probability for this point is (1/2)*(2/6)*p=2p/12.

Case (O-E) where the second roll is even with probability 3/6, from which point onwards the probability of getting an even sum when the process ends is (1-p) as the first two rolls, one being odd and the other even, have an odd sum. The net probability for this point is (1/2)*(3/6)*(1-p)=(3/12)(1-p).

Under Case (E), we have three subsequent cases:

Case (E-SE) where the second roll is the same as first (even and the same) with probability 1/6, at which point the process ends with an even sum. So, we reach this ending point with a net probability of (1/2)*(1/6)=1/12.

Case (E-DE) where the second roll is different but even with probability 2/6, from which point onwards the probability of getting an even sum when the process ends is p as the first two rolls, both being even, have an even sum. Thus, the net probability for this point is (1/2)*(2/6)*p=2p/12.

Case (E-O) where the second roll is odd with probability 3/6, from which point onwards the probability of getting an even sum when the process ends is (1-p) as the first two rolls, one being even and the other odd, have an odd sum. The net probability for this point is (1/2)*(3/6)*(1-p)=(3/12)(1-p).

Combining all the above cases we have:

p=(1/12)+(2p/12)+(3/12)(1-p)+(1/12)+(2p/12)+(3/12)(1-p).

Solving the above equation, we get p=4/7.
 
I am puzzled as to how you are so certain of your attributions onto me when you write: "you [meaning I] assumed that the third roll is Roll1 and the fourth one is Roll2". I've done no such thing.

Let's be concrete about this. Suppose the first roll of the entire game is 5 and the second roll is 3. From this point on, in order that we get an even sum for the ENTIRE game, we need to look to probability of getting an even sum, not an odd sum, for the remainder of the game. So writing (1-q), which is the probability of getting an odd sum (with a certain initial condition) for the remainder of the game is wrong. Period.

You guys are remarkable! You have a monumental inertia in not being able to see the obvious.

You obviously once again neglected to read the posts or just stubbornly refused to believe in the tightness of the arguments we presented. Check out my rebuttal three posts ago.

Anyway, that's about all i have to say about this. til next time!
 
Here's a C++ simulation

C++:
/*
* main.cpp
*
*  Created on: May 14, 2011
*      Author: tmaloney
*/

#include <iostream>
#include <ctime>
#include <cstdlib>

bool simulate_sum();
// A fair, six–sided die is rolled repeatedly and the rolls recorded.
// When two consecutive rolls are identical, the process is ended.
// Returns TRUE if the sum of all the rolls made is even, FALSE else.

int generate_roll();
// Generates random number numRand between 0 and 1. Returns 1 if 0 <= numRand < 1/6,
// 2 if 1/6 <= numRand < 2/6, 3 if 2/6 <= numRand < 3/6, 4 if 3/6 <= numRand < 4/6,
// 5 if 4/6 <= numRand < 5/6, 6 if 5/6 <= numRand <= 1

int main()
{
    using namespace std;

    // Seed the random number generator
    srand( (unsigned int)time(0) );

    int N = 1000000;
    // number of simulations
    double q(0), p(0);
    // q is prob of even, p prob of odd

    for (int i = 0; i < N; i++)
    {
        if (simulate_sum())
            q += 1;
        else
            p += 1;
    }
    cout << "The probability of even is " << q/N
            << "\nThe probability of odd is " << p/N << endl;

    return 0;
}

bool simulate_sum()
{
    int LENGTH = 1000000;
    // Upper limit of the length of the sequence
    int sequence[LENGTH];
    // Array to record sequence of rolls

    sequence[0] = generate_roll();
    sequence[1] = generate_roll();

    int i = 1;
    // counting variable
    while( i < LENGTH && sequence[i] != sequence[i-1] )
    {
        i++;
        sequence[i] = generate_roll();
    }

    int sum = 0;
    for (int k = 0; k <= i; k++)
        sum += sequence[k];

    if (sum % 2 == 0)
        return 1;
    else
        return 0;

}

int generate_roll()
{

    int a;
    double numRand;
    // numRand will be a random number between 0 and 1
    a = rand();
    numRand = static_cast<double>(a)/static_cast<double>(RAND_MAX);

    if (numRand < 1.0/6)
        return 1;
    else if (numRand < 2.0/6)
        return 2;
    else if (numRand < 3.0/6)
        return 3;
    else if (numRand < 4.0/6)
        return 4;
    else if (numRand < 5.0/6)
        return 5;
    else
        return 6;
}

Result of code:

C++:
The probability of even is 0.573052
The probability of odd is 0.426948

This results agrees with peterruse's answer.
 
Let's have two 'parallel' but uncommingled arguments going on, if you don't mind. So, please do not mingle this post (or SUB-THREAD) with the one we have been having so far. Let's call this sub-thread the quantyst's approach.

Would you please just tell me where I went wrong with my solution? Thank you.

Answer: Probability of Sum being Even is 4/7 and Probability of Sum Being Odd is 3/7.

Here's why:

Let p denote the probability of the sum being even when the game stops.

Upon the first throw, we have Case (O) an odd roll with probability 1/2, and Case (E) an even roll with probability 1/2.

Under Case (O), we have three subsequent cases:

Case (O-SO) where the second roll is the same as first (odd and the same) with probability 1/6, at which point the process ends with an even sum. So, we reach this ending point with a net probability of (1/2)*(1/6)=1/12.

Case (O-DO) where the second roll is different but odd with probability 2/6, from which point onwards the probability of getting an even sum when the process ends is p as the first two rolls, both being odd, have an even sum. Thus, the net probability for this point is (1/2)*(2/6)*p=2p/12.

Case (O-E) where the second roll is even with probability 3/6, from which point onwards the probability of getting an even sum when the process ends is (1-p) as the first two rolls, one being odd and the other even, have an odd sum. The net probability for this point is (1/2)*(3/6)*(1-p)=(3/12)(1-p).

Under Case (E), we have three subsequent cases:

Case (E-SE) where the second roll is the same as first (even and the same) with probability 1/6, at which point the process ends with an even sum. So, we reach this ending point with a net probability of (1/2)*(1/6)=1/12.

Case (E-DE) where the second roll is different but even with probability 2/6, from which point onwards the probability of getting an even sum when the process ends is p as the first two rolls, both being even, have an even sum. Thus, the net probability for this point is (1/2)*(2/6)*p=2p/12.

Case (E-O) where the second roll is odd with probability 3/6, from which point onwards the probability of getting an even sum when the process ends is (1-p) as the first two rolls, one being even and the other odd, have an odd sum. The net probability for this point is (1/2)*(3/6)*(1-p)=(3/12)(1-p).

Combining all the above cases we have:

p=(1/12)+(2p/12)+(3/12)(1-p)+(1/12)+(2p/12)+(3/12)(1-p).

Solving the above equation, we get p=4/7.
Now you are wasting my time...Nothing more to add. The explanation of Peter's logic was "milked".
 
That's where you're wrong.

Look carefully at how I've defined (q): It is the conditional probability that, given that the initial roll is odd, the sum of all rolls, including the initial roll, is even. The problem concerns itself with the sum of all rolls, not just the ones after the first roll. You are right that the sum of the rolls after the first two should be even if the first two are odd, but that's not what we're concerned with. We're concerned with the fact that the problem resets once the second roll is different from the first, so that the second roll is now treated as the initial roll and the sum starting with the second roll indeed must be odd because the first roll was odd.

You wrote above that: "so that the second roll is now treated as the initial roll". This means that you are actually ignoring the very first roll of the ENTIRE game. But you cannot do that as we must look at the TOTAL sum of the ENTIRE game. If the first roll is, say, five and the second roll is, say, three, then up to this point in the game we have an even sum and to get an even sum for the entire game, we need to look to an even sum for the remainder of the game after the first two odd rolls of 5 and 3. Your solution is wrong.

Why don't you show your solution (as well as mine) to a number of PROBABILITY professors, not just anyone? And let's see what they say and how they say it. So, send your and my solutions to some ten or so professors specializing in probability and maybe a few of them will send back a response.
 
Thank you for the good work.

Just one request. Can you please show me the algorithm used in your code so that I can better relate to your code? Thank you for your response.

Here's a C++ simulation

C++:
/*
* main.cpp
*
*  Created on: May 14, 2011
*      Author: tmaloney
*/

#include <iostream>
#include <ctime>
#include <cstdlib>

bool simulate_sum();
// A fair, six–sided die is rolled repeatedly and the rolls recorded.
// When two consecutive rolls are identical, the process is ended.
// Returns TRUE if the sum of all the rolls made is even, FALSE else.

int generate_roll();
// Generates random number numRand between 0 and 1. Returns 1 if 0 <= numRand < 1/6,
// 2 if 1/6 <= numRand < 2/6, 3 if 2/6 <= numRand < 3/6, 4 if 3/6 <= numRand < 4/6,
// 5 if 4/6 <= numRand < 5/6, 6 if 5/6 <= numRand <= 1

int main()
{
    using namespace std;

    // Seed the random number generator
    srand( (unsigned int)time(0) );

    int N = 1000000;
    // number of simulations
    double q(0), p(0);
    // q is prob of even, p prob of odd

    for (int i = 0; i < N; i++)
    {
        if (simulate_sum())
            q += 1;
        else
            p += 1;
    }
    cout << "The probability of even is " << q/N
            << "\nThe probability of odd is " << p/N << endl;

    return 0;
}

bool simulate_sum()
{
    int LENGTH = 1000000;
    // Upper limit of the length of the sequence
    int sequence[LENGTH];
    // Array to record sequence of rolls

    sequence[0] = generate_roll();
    sequence[1] = generate_roll();

    int i = 1;
    // counting variable
    while( i < LENGTH && sequence[i] != sequence[i-1] )
    {
        i++;
        sequence[i] = generate_roll();
    }

    int sum = 0;
    for (int k = 0; k <= i; k++)
        sum += sequence[k];

    if (sum % 2 == 0)
        return 1;
    else
        return 0;

}

int generate_roll()
{

    int a;
    double numRand;
    // numRand will be a random number between 0 and 1
    a = rand();
    numRand = static_cast<double>(a)/static_cast<double>(RAND_MAX);

    if (numRand < 1.0/6)
        return 1;
    else if (numRand < 2.0/6)
        return 2;
    else if (numRand < 3.0/6)
        return 3;
    else if (numRand < 4.0/6)
        return 4;
    else if (numRand < 5.0/6)
        return 5;
    else
        return 6;
}

Result of code:

C++:
The probability of even is 0.573052
The probability of odd is 0.426948

This results agrees with peterruse's answer.
 
Thank you for the good work.

Just one request. Can you please show me the algorithm used in your code so that I can better relate to your code? Thank you for your response.
I put comments into the code, but I just wrote it now so I may have missed some parts. It's hard for me to explain the algorithm without pointing to the code itself. The basic idea is to simulate the rolling of the die using a random number generator (the RNG is provided by C++). I record the results in an array, and sum the numbers, then test if the result is even or odd. If it's even, I tally the variable q up by 1. I repeat the experiment N=1,000,000 times, each time adding 1 to q if the sum if even. Then the probability that the sum is even is q/N. Let me know if you have any more questions.
 
One specific pitfall is specifying the length of the array. It's possible to have an infinite sequence of rolls without having a repeated consecutive number. So I set the length really big, to 1,000,000.
 
I just discovered a serious conceptual but subtle error in my solution. In one of the steps in my approach I've assumed something that's not the case. Quite a learning experience! I will need to spend some time correcting my approach. I will probably come back to admit other errors. I just need time to go over a number of details. Will be back ...
 
Back
Top