Odds problem - roll a pair of dice

I’ll state in advance that I’m under the influence of cold medication today. Still, I didn’t think it would be a challenge to write a quick-and-dirty Python simulation to test this out.


import random

def roll(dice, sides):
    roll = 0
    for i in range(0, dice):
        roll += random.randint(1,sides)
    return roll

is_a_six = 0
total = 0

# Repeat one million times
for i in range(0, 1000000):
    no_six = 1

# Roll two dice until at least one of them is a six
    while no_six:
        red_die = roll(2, 6)
        green_die = roll(2, 6)
        no_six = (red_die != 6 and green_die != 6)

# If both are six, discard one at random
    if (red_die == 6) and (green_die == 6) :
        if roll(1, 2) == 1:
            remaining_die = green_die
        else :
            remaining_die = red_die
            
# If only one is a six, discard that one
    elif red_die == 6 :
            remaining_die = green_die
    else :
        remaining_die = red_die
            
# See if the remaining die is a six
    if remaining_die == 6 :
        is_a_six += 1
    total += 1

# Display the results
ratio = round(float(total)/float(is_a_six), 2)
print("Is a six :  {}").format(is_a_six)
print("Not a six : {}").format(total - is_a_six)
print("It's a six about 1/{} of the time.").format(ratio)


It returned this:

1/13? That’s an answer that wasn’t on anybody’s radar. I repeated it five times with the same result. I’m probably overlooking something really obvious.

The way that two-child problem is usually stated is parallel to the two dice problem.

A poll worker knocks on the door, and a woman answers. The woman tells the poll worker that she, her husband, and their two children live there. The poll worker asks if she has at least one boy, the woman replies “yes.” What’s the probability that BOTH kids are boys?

Answer: 1/3

Did you seed the random number generator? Python is one of the few languages I’ve never done, but I don’t see a statement to initialize the RNG in there.

I’m not a python expert, but I’d wonder about the random generator first, and how it is seeded.

Python uses the system time as a seed by default. I should have been clearer that I didn’t get exactly the same results each time I ran it, but the result is always between 1/13.30 and 1/13.42.

Also: The “roll” function is one I’ve used in many programs to simulate die rolls. I’ve checked the distribution with various numbers of different-sided dice. It’s reliable.

Ok, I will play. I still say the OP is ambiguous. I will set the conditions, and you tell me where my conditions violate the OP.

1.) Use two fair six sided dice.

2.) I put up $100 and state I am betting on double six. You put up $700.

3.)The dice are rolled, but I can’t see the result.

4.)You show me one die, proving it is a six. If you don’t show me a six, everyone takes back the money they put in the pot and return to step 1. If you do show me a six, go to the next step.

5.) Show me the other die. If it is double sixes, I get the pot. If it is not double sixes, you get the pot.

Okay say far? Oh, one more thing.

6.) I don’t have to bet on six every time. I can bet on any number. If I bet on ones, I win with double ones, etc. If you don’t show me a one first, I get my $110 back. In fact, I can place multiple bets on each roll. I will probably place a $100 bet on every number, one through six, every roll.

Still wanna bet? Why not? Does Step 6 violate the OP in any way?

See why the OP is ambiguous if you don’t specify why six is chosen?

Yes, they are independent no more.

They are connected because you now know that the two dice belong to a specific set of possible outcomes.

1,6
2,6
3,6
4,6
5,6
6,6
6,1
6,2
6,3
6,4
6,5

Only one of the 11 possible combinations includes 2 sixes.

One die does not affect the other, but given the specific sets of pairs, looking at one of the pair gives you limited options for the other in the pair.

For example, if one of the dice is a 1, the other has to be a 6. One die does not affect the other, but knowing one of them is a 1 tells you the other has to be a 6. There are no other possible outcomes among this group.

Likewise, if one of the dice is a 6, the other die has a 2-11 chance of being a 1. A 2-11 chance of being a 2. A 2-11 chance of being a 3. A 2-11 chance of being a 4. A 2-11 chance of being a 5. And a 1-11 chance of being a 6.

I tried it with real dice and my results were appearing to converge to 1/11. The results are above in another post.

Do it with 2 real dice as described and tally the results like I did for damn near an hour of continuous rolls and you won’t get 1/6. You will get closer to 1/11. I was even arguing strenuously for 1/6 and making a bit of an ass of myself in the process. And here I am eating my crow!

Different numbers have different odds in the OPs problem. 5 of them are 2/11. 1 of them is 1/11. So it doesn’t make sense for the house to take that bet. Since (2/11*5+1/11)6100<700 the house always loses 100. Yet the 7/1 odds is a winner for the house. Look all it takes to see the right answer are two dice, a pen, and some paper. Oh and an hour.

Okay, why do the different numbers have different odds, and how did you figure that out? I think that they’re all at 1/11; there’s no reason they should add up to 1.

Now, I do think the proposition changes if the punter can “call” two numbers at a time on the same roll, though I haven’t worked out the details.

I don’t know anything about Python. But it looks like you are using a 7 sided die.

for i in range(0, dice):

0 to dice would count 0 as a side. So 0, 1, 2, 3, 4, 5 ,6 are valid results. So that’s my guess with a minute looking at the code.

Well, the sum of all probabilities of all possible events has to equal 1.

There are 11 ordered pairs that show at least 1 6.

1,6
2,6
3,6
4,6
5,6
6,6
6,1
6,2
6,3
6,4
6,5

If I show you a 6, the other die can be 1,2,3,4,5 for two events or 6 for one event.

So the probabilities are 2/11 for a 1, 2/11 for a 2, 2/11 for a 3, 2/11 for a 4, 2/11 for a 5, and 1/11 for a 6. These are all the possibilities for possible events and the sum is 1.

Ok rereading that Python this is what I’m getting.

I don’t about Python but it looks readable.

This code is confusing me.

def roll(dice, sides):
roll = 0
for i in range(0, dice):
roll += random.randint(1,sides)
return roll

Help me out. This looks like a function definition. Looks like a roll function is being defined with two parameters. dice and sides.

You initialize the value to 0.
Then for i = 0 to 2 according to the function call later you roll a 6 sided die and add the value to roll.
Why are you adding 3 die rolls for each die?

red_die = roll (2,6)?

Is that correct? Shouldn’t the red die only iterate once? From 0 to 0 or whatever python needs to do the loop once?

Never mind

THAT’S IT! Thanks! I knew I was missing something simple. I had pulled part of the code from a program that was demonstrating the probability distribution of two six-sided dice, and I neglected to change the 2 to a 1 for this program.

Changing it to


    while no_six:
        red_die = roll(1, 6)
        green_die = roll(1, 6)
        no_six = (red_die != 6 and green_die != 6)


I now get

That makes more sense. Though I expected to get 1/6.

A good guess, but in Python:

I love pairs of dice as pedagogical aids. A few notes come to mind.

First, the mutually fair, independent die face pairs yield 36 pairs, each of the form (d1,d2), with probability Pr{(d1,d2)} = Pr{1st die shows d1}Pr{2nd die shows d2} = (1/6)(1/6) = 1/36.

Next, my reading of the problem is best treated as a conditional event of the form “both faces show 6 given that one or more faces show 6”.

Then the prior event is “one or more of the faces show 6” and then Pr{prior} = Pr{(1,6),(2,6),(3,6),(4,6),(5,6),(6,6),(6,1),(6,2),(6,3),(6,4),(6,5)} = 11*(1/36).

The joint event is that both faces show 6, and then Pr{joint} = Pr{(6,6)}=1/36.

Then the conditional probability is then (1/36)/(11/36) = 1/11.

Note that the independent bit is built into the pair probability model.

Musicat, please go over the exchange between us. Pay particular attention to the bolded parts.

I asked you about both. So can you please answer my question?:

Then the omniscient viewer says, “Look, you rolled at least one six.” At that point, what is the chance both dice are 6s?

Or as I mentioned, RedSwinglineOne asked essentially the same question in full in post 187:

“Two fair dice are rolled. If at least one is a six, what are the odds they are both sixes?”

For those who say it is not ambiguous, I will make it as simple as possible.

OP in bold.

Two fair dice are rolled together,

** and you are told that ‘at least one of the dice is a 6.’ A 6 is removed,

**I can see both die. I pull out $1000. I say, "For $10, I will show you the other die. If the other die is also a six, you win the $1000. If it is not a six, I keep your $10.

** and you are t{h}en shown the other die.

**Who takes that bet as stated?