ChatGPT Meets Elchanan Mossel’s Dice Problem

One of the greatest hits of this blog was Elchanan Mossel’s dice problem, asked here and answered here. Here is how chatGPT (the free version) handles the problem.

You throw a die until you get 6. What is the expected number of throws (including the throw giving 6) conditioned on the event that all throws gave even numbers?

dice-chatGPT-1dice-chatGPT-2

Small additions to the post:

1) Here are the results of a poll we had in 2017 about the answer

mossel-poll

2. 3 is not the correct answer.

3. ChatGPT gets the right answer to the more basic question: You throw a die until you get 6. What is the expected number of throws (including the throw giving 6).

4. Luca Trevisan pointed out on FB a more extreme version of this problem (from a discussion on  Reddit) where it defines

A= the expected number of rolls until you get the 100th 6, conditioned on rolling all evens, and

B = the expcted number of rolls until you get, for the first time, 100 6s in a row, conditioned on rolling all evens.

The claim was that both A and B are very close to 100, and that B<A, because of the way the conditioning disfavors long strings, and puts most of the probability on the shortest ways of achieving the condition.

(The naive incorrect computation will give you 300 for A and 3^{100} for B.)

5. For a discussion of the original question see on Math with bad drawing: A Probability Puzzle That You’ll Get Wrong  ; On Mike’s math page: Exploring Elchanan Mossel’s fantastic probability problem with kids;  ;  Understanding The Math Behind Elchanan Mossel’s Dice Paradox; A recent discussion on Reddit; and quite a few other places…

Here is a very nice video by MindYourDecision

This entry was posted in AI, Probability, Riddles, Test your intuition and tagged , , . Bookmark the permalink.

17 Responses to ChatGPT Meets Elchanan Mossel’s Dice Problem

  1. Gil Kalai says:

    If some reader has access to ChatGPT4 it would be nice to try it.

  2. zevahcle says:

    chatGPT 4 answer:

    The probability of getting an even number on a die is 1/2, since there are three even numbers (2, 4, and 6) out of six possible outcomes. When we condition on the event that all throws are even, we essentially have a new die with only three sides (2, 4, and 6). Now we want to find the expected number of throws to get a 6 with this new three-sided die.

    The probability of rolling a 6 in this case is 1/3, since there’s only one favorable outcome out of the three possible even numbers.

    To calculate the expected number of throws to get a 6, we can use the geometric distribution’s expectation formula, which is 1/p, where p is the probability of success (in this case, rolling a 6).

    So the expected number of throws would be 1/(1/3), which equals 3.

    Therefore, conditioned on the event that all throws gave even numbers, the expected number of throws until getting a 6 is 3.

    • Gil Kalai says:

      Thanks! It looks that ChatGPT (even the free version) can produce a Python program for simulating the problem but not able to “run” the program and use it for answering the problem.

  3. repton says:

    Ok, so here’s my python program to try to simulate this. When I run it, I consistently get a number around 3. What have I done wrong?

    from random import randint

    def seq():
    count = 1
    roll = randint(1,6)
    while roll != 6:
    if roll == 2 or roll == 4:
    count += 1
    roll = randint(1,6)
    return count

    def repeat(trials):
    total = 0
    for i in range(trials):
    total += seq()
    return total / trials

    repeat(10000)

    • repton says:

      Oh man, WordPress squashed my whitespace. Here it is again, with ‘.’ standing in for tab:

      from random import randint

      def seq():
      .count = 1
      .roll = randint(1,6)
      .while roll != 6:
      ..if roll == 2 or roll == 4:
      …count += 1
      ..roll = randint(1,6)
      .return count

      def repeat(trials):
      .total = 0
      .for i in range(trials):
      ..total += seq()
      .return total / trials

      repeat(10000)

  4. Avi Levy says:

    You can reduce to a three-sided die but then your die is weighted with p(2)=p(4)=1/6 and p(6)=2/3 (because you are collapsing outcomes {1,3,5,6} into 6). ChatGPT and gpt4 make the same mistake many humans make who try to reduce to a three-sided die but don’t consider the distribution on {2,4,6} – falling into the trap of automatically assuming all probability distributions are uniform. I wonder what would happen if you pressed the gpts on this point, asking them to explain how they determine which distribution to use on {2,4,6}.

  5. Gil Kalai says:

    I asked chatGPT “You throw a die until you get 6. What is the expected number of throws (including the throw giving 6)?”

    On one occasion the answer was

    a) To find the expected number of throws until you get a 6 (including the throw giving 6), you can use the concept of a geometric distribution. A geometric distribution models the number of trials needed for a success to occur in a sequence of independent Bernoulli trials, where each trial has the same probability of success.

    In this case, the probability of success (rolling a 6) in each trial is 1/6 because there is a 1/6 chance of rolling a 6 on a fair six-sided die. The probability of failure (not rolling a 6) in each trial is 5/6.

    The expected number of throws (including the throw giving 6) can be calculated as:

    E(X) = 1 / P(success)

    E(X) = 1 / (1/6) = 6

    So, the expected number of throws to get a 6, including the throw giving 6, is 6.

    On another occasion the answer was 1 and did not make much sense.

    https://gilkalai.files.wordpress.com/2023/11/chatgptsix.jpg

    (Bard gave me three drafts with the answers 5/6, 3/2, and 6 )

  6. Andrew L says:

    Treating it as an absorbing Markov Chain, the only thing that matters is the probability of staying in the transient state, which is 1/3. Since this is a scalar, the fundamental matrix is also a scalar, (1-1/3)^-1, which corresponds to the expected number of steps before leaving the transient state, or 3/2.

    The result then is independent of whether the absorbing state is a 6 or an odd roll. So if the question was “how many rolls to get a 5 or a 6 conditioned on all previous rolls being even” the answer is the same. This is wildly unintuitive to me.

  7. Hey, the reddit person here. Cool to see that the paradox a friend and I came up with (inspired by your earlier blog) made it to the same blog. In unpacking that paradox, the following idea came up:

    Modify your original problem to “Expected number of rolls until the first 6, given that no odds showed up until after both the first 6 and the Nth roll”.

    Intuitively, one might think the answer remains unchanged since we’re only adding conditions after the first 6. But as N goes to infinity, this expectation goes to 3 (matching the 3-sided die intuition).

    This is also the key to understanding our paradox – if you let C be “expected number of rolls until the 100th 6, given that no odds show up until after the first instance of 100 6s in a row”, you have A>=C by basic measure theory. But the key is understanding that B and C are *not* equal and so B>A is possible.

  8. robertsamal says:

    Hi, I know I am a bit late to the party, but perhaps somebody will still be interested. I tried GPT-4 (paid version) and had extensive discussion with it. It consistently says the expected number of throws is 3. It can create a python script and run it for me. At first try it was just sampling random numbers in {2,4,6}. But it can show the code and after being explained why it is wrong, it writes a new code that gives the correct answer. However, even after that it cannot “change its mind”. (I know it technically has no mind, most likely …)

    Here is the chat, if anyone is interested to read through it.
    https://chat.openai.com/share/37432585-8712-4d5b-be37-a730047c9887

    What I found exciting about this chat, is that it felt like a discussion with a below-average student, who is dutifully trying to apply learned formulas.

  9. Pingback: 222nd Carnival of Mathematics

  10. Pingback: 222nd Carnival of Mathematics - SoatDev IT Consulting

  11. Pingback: 222nd Carnival of Mathematics – Silicon Hype

  12. Pingback: 222nd Carnival of Mathematics – Dinezh.com

  13. Pingback: Carnival 170: A Plethora of Playful Math – Denise Gaskins' Let's Play Math

Leave a comment