# Let's make a deal (about a really, really beaten dead horse)

**URL:** <https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576>\
**Category:** Cecil's Columns/Staff Reports\
**Created:** [July 15, 2013, 5:34pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576 "2013-07-15T17:34:57Z")\
**Posts on this page:** 20\
**Page:** 6

<div class="post-metadata">

**Author:** ![g0barth](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@g0barth](https://boards.straightdope.com/u/g0barth)\
**Post date:** [August 10, 2013, 6:20pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/101 "2013-08-10T18:20:42Z")

</div>

Far down the original 1990 post, is the problem of a family with two children. A reliable report comes to you that one of the two children is a girl. What is the sex of the other child in this family? Cecil claims that the probability is 2/3 that it is a boy. In other words, if you visit the family after receiving such a report, you would find in two of three visits: Mom and Dad, and a brother and sister. Unfortunately, this answer is false.

In the big, wide world, the family with two daughters will generate two reports of “This family has a daughter” for every one report generated by a family with one daughter and one son. Why? Because they have two daughters running around and being observed whereas the family with one daughter and one son has only one daughter running around. However, there are two families with one daughter and one son for every family with two daughters (the “odds” structure. See ^^^ below). So, families with two daughters, and families with one daughter and one son, end up generating the same number reports.

As an “intelligence analyst” all you get are the reports. Half those reports come from families with two daughters and half come from families with one daughter and one son. If you get such a report and then visit the family, half the time that family will have two daughters and half the time that family will have a daughter and a son.

When you account for report frequency, the report that a family with two children has a daughter tells you nothing about the sexual identity of the other child. This is exactly what we would expect and it is exactly the point being made by Adam Martin and Anna Davlantes of Evanston, Illinois way back when.

^^^^When we look only at sex and two children families there are only four types: g/g, g/b, b/g, b/b. When you eliminate “b/b”, only three remain and two of the these three family types have a boy. The odds that one of these families has a boy is 2 in 3. We use these odds to calculate the distribution of reports. However, the odds of a boy are not the same as the predictive power of the report. And it is predictive power that interests people.

---

<div class="post-metadata">

**Author:** ![John\_W.Kennedy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/john_w.kennedy/32/1031_2.png) [@John\_W.Kennedy](https://boards.straightdope.com/u/John_W.Kennedy)\
**Post date:** [August 11, 2013, 2:43pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/102 "2013-08-11T14:43:55Z")

</div>

This has nothing to do with the problem as stated.

---

<div class="post-metadata">

**Author:** ![PalmerEldritch](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@PalmerEldritch](https://boards.straightdope.com/u/PalmerEldritch)\
**Post date:** [August 12, 2013, 1:37am UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/103 "2013-08-12T01:37:13Z")

</div>

> [@John\_W.Kennedy](#):
>
> This has nothing to do with the problem as stated.

The problem as stated is “There is a family with two children. _ **You have been told this family has a daughter** _. What are the odds they also have a son, assuming the biological odds of having a male or female child are equal?”

The sentence italicised and in bold is crucial to calculating the answer. The probability of being told the family has a daughter for each family type is:

If BB then Prob(“told family has a daughter”) = 0  
If BG then Prob(“told family has a daughter”) = 1/2  
If GB then Prob(“told family has a daughter”) = 1/2  
If GG then Prob(“told family has a daughter”) = 1

This makes the answer to the problem _ **as stated** _ = 1/2

2/3 is the answer to a different problem, unless you’re making assumptions that are neither specified nor implied in the problem.

---

<div class="post-metadata">

**Author:** ![Megacannon](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Megacannon](https://boards.straightdope.com/u/Megacannon)\
**Post date:** [August 13, 2013, 1:45pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/104 "2013-08-13T13:45:31Z")

</div>

For what it’s worth, I’ve written a small C# command line application to let you play this game repeatedly. Having done it myself, there’s a clear disadvantage to not switching doors.

You can download it here.  
[http://www.mediafire.com/?x8xf2f8fm0bs3ed](http://www.mediafire.com/?x8xf2f8fm0bs3ed)

In the interest of full disclosure, here’s the source code.

```auto

using System;
using System.Text;

namespace monty
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(" **************************************");
            Console.WriteLine("* Welcome to Monty *");
            Console.WriteLine(" **************************************");
            Console.WriteLine(" ");

            bool keepPlaying = true;
            Random rand = new Random();
            int winningDoor;
            int montysChoice;
            int usersChoice;
            double totalCount = 0;
            double winCount = 0;
            String userInput;

            while (keepPlaying == true)
            {
                usersChoice = 0;
                montysChoice = 0;
                winningDoor = rand.Next(1, 3);

                Console.WriteLine("There are three doors. Please enter your choice (1, 2, or 3): ");
                userInput = Console.ReadLine();
                usersChoice = Convert.ToInt32(userInput);

                Console.WriteLine("Monty will now pick a door of the remaining two.");

                if (usersChoice == 1)
                {
                    if (usersChoice != winningDoor)
                    {
                        if (winningDoor == 2) { montysChoice = 3; }
                        else { montysChoice = 2; }
                    }
                    else { montysChoice = rand.Next(2, 3); }
                }
                else if (usersChoice == 2)
                {
                    if (usersChoice != winningDoor)
                    {
                        if (winningDoor == 1) { montysChoice = 3; }
                        else { montysChoice = 1; }
                    }
                    else
                    {
                        montysChoice = rand.Next(1, 3);

                        while (montysChoice == usersChoice || montysChoice == winningDoor)
                        {
                            montysChoice = rand.Next(1, 3);
                        }
                    }
                }
                else //Assume user picked number 3
                {
                    if (usersChoice != winningDoor)
                    {
                        if (winningDoor == 1) { montysChoice = 2; }
                        else { montysChoice = 1; }
                    }
                    else { montysChoice = rand.Next(1, 2); }
                }

                Console.WriteLine("Monty has chosen door number " + montysChoice + ". And revealed it to be a dud.");
                Console.WriteLine("Do you want to switch doors? (y or n) ");

                userInput = Console.ReadLine();

                if (userInput == "y")
                {
                    if (usersChoice == 1 && montysChoice == 2)
                        usersChoice = 3;
                    else if (usersChoice == 1 && montysChoice == 3)
                        usersChoice = 2;
                    else if (usersChoice == 2 && montysChoice == 1)
                        usersChoice = 3;
                    else if (usersChoice == 2 && montysChoice == 3)
                        usersChoice = 1;
                    else if (usersChoice == 3 && montysChoice == 1)
                        usersChoice = 2;
                    else if (usersChoice == 3 && montysChoice == 2)
                        usersChoice = 1;
                }

                if (usersChoice == winningDoor)
                { 
                    Console.WriteLine("Congratulations! Door " + usersChoice + " was the winning door!");
                    winCount++;
                    totalCount++;
                }
                else
                { 
                    Console.WriteLine("Sorry. Door " + usersChoice + " was not the winning door.");
                    totalCount++;
                }

                Console.WriteLine("Wins: " + winCount + " Total Games: " + totalCount + " Win %: " + winCount / totalCount);
                Console.WriteLine("Play again? (y or n) ");
                userInput = Console.ReadLine();

                if (userInput == "n") { keepPlaying = false; }
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Cartoonacy](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@Cartoonacy](https://boards.straightdope.com/u/Cartoonacy)\
**Post date:** [August 13, 2013, 4:58pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/105 "2013-08-13T16:58:25Z")

</div>

> [@PalmerEldritch](#):
>
> The problem as stated is “There is a family with two children. _ **You have been told this family has a daughter** _. What are the odds they also have a son, assuming the biological odds of having a male or female child are equal?”
> 
> The sentence italicised and in bold is crucial to calculating the answer.

Yes, it is crucial, but not in the way you claim. It says “You _ **have** _ been told.” Calculating the odds of what you were already told is irrelevant to answering the question as stated. It’s a given. You _ **have** _ been told, so the probability is 1. Given that you _ **have** _ been told this family has a daughter, _then_ what are the odds they also have a son?

---

<div class="post-metadata">

**Author:** ![Megacannon](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Megacannon](https://boards.straightdope.com/u/Megacannon)\
**Post date:** [August 13, 2013, 8:27pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/106 "2013-08-13T20:27:46Z")

</div>

> [@Megacannon](#):
>
> For what it’s worth, I’ve written a small C# command line application to let you play this game repeatedly. Having done it myself, there’s a clear disadvantage to not switching doors.

You can disregard this program until I’ve fixed it. There’s a problem with the algorithm I made. For some reason, you can get a 100% win chance if you always pick door 3 and always elect to switch doors. Obviously, something is wrong.

---

<div class="post-metadata">

**Author:** ![bup](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@bup](https://boards.straightdope.com/u/bup)\
**Post date:** [August 13, 2013, 8:56pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/107 "2013-08-13T20:56:00Z")

</div>

> [@Megacannon](#):
>
> You can disregard this program until I’ve fixed it. There’s a problem with the algorithm I made. For some reason, you can get a 100% win chance if you always pick door 3 and always elect to switch doors. Obviously, something is wrong.

From Microsoft Developer Network of Random’s Next method:

> [@Microsoft](#):
>
> Return Value  
> Type: System.Int32  
> A 32-bit signed integer greater than or equal to minValue and _less than maxValue_; that is, the range of return values includes minValue _but not maxValue_. If minValue equals maxValue, minValue is returned.

So make it

winningDoor = rand.Next(1, 4);

(and similar fixes for the situations where Monty has to choose between 2 remaining doors).

---

<div class="post-metadata">

**Author:** ![Megacannon](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Megacannon](https://boards.straightdope.com/u/Megacannon)\
**Post date:** [August 14, 2013, 12:38am UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/108 "2013-08-14T00:38:53Z")

</div>

> [@](#):
>
> greater than or equal to minValue and less than maxValue;

Thanks for looking that up for me. I figured it was something like that. (_“It’s probably some “greater than/equal to” bug. But there’s no way they would do it that way–it’s too stupid. I don’t have time for this; I need to get back to work.”_ - Me after I found the bug). I thought my numbers seemed off when I was getting a 75% success rate.

---

<div class="post-metadata">

**Author:** ![PalmerEldritch](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@PalmerEldritch](https://boards.straightdope.com/u/PalmerEldritch)\
**Post date:** [August 14, 2013, 2:16am UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/109 "2013-08-14T02:16:40Z")

</div>

> [@Cartoonacy](#):
>
> Yes, it is crucial, but not in the way you claim. It says “You _ **have** _ been told.” Calculating the odds of what you were already told is irrelevant to answering the question as stated. It’s a given. You _ **have** _ been told, so the probability is 1. Given that you _ **have** _ been told this family has a daughter, _then_ what are the odds they also have a son?

It’s not a given, if it was the problem would be stated “Given that I have 2 children of which at least one is a boy etc…”  
Presumably if I’d been _ **told** _ instead that “at least one was a girl” I’d have to calculate the probability that both were girls as 1/3 also. So whatever I’m _ **told** _ I’m supposed to calculate the probability that both children are of the same gender as 1/3?  
Apply your logic to the Monty Hall Problem. According to you it’s a “given” that Monty opens Door3 (since calculating the odds of what door has **already** been opened is irrelevant), if that’s the case there’s no advantage in switching - it’s 50/50, but you and I both know that’s the wrong answer.  
Just because something didn’t happen doesn’t mean it couldn’t happen. Just because you’ve been told “at least one is a boy” doesn’t mean you couldn’t have been told “at least one is a girl”

---

<div class="post-metadata">

**Author:** ![Megacannon](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Megacannon](https://boards.straightdope.com/u/Megacannon)\
**Post date:** [August 14, 2013, 2:20pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/110 "2013-08-14T14:20:55Z")

</div>

Here we go. I fixed the program and made it much better overall. It now uses truly random numbers from [Random.org](http://Random.org) and is also much more robust than before. Requires an Internet connection to play. 😛

> **[monty](http://www.mediafire.com/file/c0e2tikbeah4sbf/monty.exe/file)**
>
> MediaFire is a simple to use free service that lets you put all your photos, documents, music, and video in a single place so you can access them anywhere and share them everywhere.

Full disclosure code:

```auto

using System;
using System.Text;
using System.Net;
using System.IO;

namespace monty
{
    class Program
    {
        
        static int Main(string[] args)
        {
            int[] rand;
            rand = GetRandomNumbers(2000, 1, 3);

            if (rand == null)
                return 1;

            Console.WriteLine("");
            Console.WriteLine(" **************************************");
            Console.WriteLine("* Welcome to Monty *");
            Console.WriteLine(" **************************************");
            Console.WriteLine("");

            bool keepPlaying = true;
            int winningDoor;
            int montysChoice;
            int usersChoice;
            double totalCount = 0;
            double winCount = 0;
            int next = 0;
            String userInput;

            while (keepPlaying == true)
            {
                usersChoice = 0;
                montysChoice = 0;
                winningDoor = rand[next];
                next++;

                Console.WriteLine("There are three doors. Please enter your choice (1, 2, or 3): ");
                userInput = Console.ReadLine();
                usersChoice = Convert.ToInt32(userInput);

                Console.WriteLine("Monty will now pick a door of the remaining two.");

                if (usersChoice == 1)
                {
                    if (usersChoice != winningDoor)
                    {
                        if (winningDoor == 2) { montysChoice = 3; }
                        else { montysChoice = 2; }
                    }
                    else 
                    {
                        montysChoice = rand[next];
                        next++;

                        while (montysChoice == 1)
                        {
                            montysChoice = rand[next];
                            next++;
                        }
                        
                    }
                }
                else if (usersChoice == 2)
                {
                    if (usersChoice != winningDoor)
                    {
                        if (winningDoor == 1) { montysChoice = 3; }
                        else { montysChoice = 1; }
                    }
                    else
                    {
                        montysChoice = rand[next];
                        next++;

                        while (montysChoice == 2)
                        {
                            montysChoice = rand[next];
                            next++;
                        }
                    }
                }
                else //Assume user picked number 3
                {
                    if (usersChoice != winningDoor)
                    {
                        if (winningDoor == 1) { montysChoice = 2; }
                        else { montysChoice = 1; }
                    }
                    else 
                    {
                        montysChoice = rand[next];
                        next++;

                        while (montysChoice == winningDoor)
                        {
                            montysChoice = rand[next];
                            next++;
                        }
                    }
                }

                Console.WriteLine("Monty has chosen door number " + montysChoice + ". And revealed it to be a dud.");
                Console.WriteLine("Do you want to switch doors? (y or n) ");

                userInput = Console.ReadLine();

                if (userInput == "y")
                {
                    if (usersChoice == 1 && montysChoice == 2)
                        usersChoice = 3;
                    else if (usersChoice == 1 && montysChoice == 3)
                        usersChoice = 2;
                    else if (usersChoice == 2 && montysChoice == 1)
                        usersChoice = 3;
                    else if (usersChoice == 2 && montysChoice == 3)
                        usersChoice = 1;
                    else if (usersChoice == 3 && montysChoice == 1)
                        usersChoice = 2;
                    else if (usersChoice == 3 && montysChoice == 2)
                        usersChoice = 1;
                }

                if (usersChoice == winningDoor)
                { 
                    Console.WriteLine("Congratulations! Door " + usersChoice + " was the winning door!");
                    winCount++;
                    totalCount++;
                }
                else
                { 
                    Console.WriteLine("Sorry. Door " + usersChoice + " was not the winning door.");
                    totalCount++;
                }

                Console.WriteLine("Wins: " + winCount + " Total Games: " + totalCount + " Win %: " + winCount / totalCount);
                Console.WriteLine("Play again? (y or n) ");
                userInput = Console.ReadLine();

                if (userInput == "n") { keepPlaying = false; }
            }

            return 0;
        }

        static int[] GetRandomNumbers(int quantity, int lowerBound, int upperBound)
        {
            Console.WriteLine("Retrieving random numbers from Random.org...");

            Console.WriteLine("Checking quota...");
            bool quotaExceeded = false;
            quotaExceeded = CheckQuotaIsExceeded();

            if (quotaExceeded == true)
            {
                Console.WriteLine("Quota for this IP address has been met or exceeded. Stopping.");
                int[] failure = null;
                return failure;
            }
            else
            {
                Console.WriteLine("Quota check OK.");
            }

            String strRequestURL = "http://www.random.org/integers/?num=" + quantity +
                "&min=" + lowerBound + "&max=" + upperBound + "&col=1&base=10&format=plain&rnd=new";
            WebRequest webRequest = WebRequest.Create(strRequestURL);

            int[] results = new int[quantity];

            try
            {
                Stream objStream = webRequest.GetResponse().GetResponseStream();
                StreamReader objReader = new StreamReader(objStream);

                string line = "";
                for (int i = 0; line != null && i < quantity; i++)
                {
                    line = objReader.ReadLine();
                    results* = Convert.ToInt32(line);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Retrieval of random numbers failed.");
                Console.WriteLine("Exception: " + ex.Message);
            }

            Console.WriteLine("Numbers retrieved successfully.");

            return results;
        }

        static bool CheckQuotaIsExceeded()
        {
            String strRequestURL = "http://www.random.org/quota/?format=plain";
            WebRequest webRequest = WebRequest.Create(strRequestURL);

            Stream objStream = webRequest.GetResponse().GetResponseStream();
            StreamReader objReader = new StreamReader(objStream);

            String strQuota = objReader.ReadLine();

            if (Convert.ToInt32(strQuota) <= 0)
                return true;
            else
                return false;

        }
    }
}

```

PS: I didn’t write it to look pretty.

---

<div class="post-metadata">

**Author:** ![Cartoonacy](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@Cartoonacy](https://boards.straightdope.com/u/Cartoonacy)\
**Post date:** [August 14, 2013, 2:49pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/111 "2013-08-14T14:49:56Z")

</div>

> [@PalmerEldritch](#):
>
> It’s not a given, if it was the problem would be stated “Given that I have 2 children of which at least one is a boy etc…”

There are other ways to establish something as a given without using the word “given.” Putting it in the past tense, for example.

> [@PalmerEldritch](#):
>
> Just because something didn’t happen doesn’t mean it couldn’t happen.

No. but it does mean that it didn’t happen. Unless you’re a time traveler, something that already happened has a probability of 1, and something that didn’t happen has a probability of 0.

> [@PalmerEldritch](#):
>
> Apply your logic to the Monty Hall Problem. According to you it’s a “given” that Monty opens Door3 (since calculating the odds of what door has **already** been opened is irrelevant), if that’s the case there’s no advantage in switching - it’s 50/50, but you and I both know that’s the wrong answer.

I don’t understand what you’re trying to say here. But in the Monty Hall problem, the given is that Monty opened a door that he knew didn’t have the prize behind it. The player, knowing this, now has new information that changes the odds.

---

<div class="post-metadata">

**Author:** ![bup](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@bup](https://boards.straightdope.com/u/bup)\
**Post date:** [August 14, 2013, 3:43pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/112 "2013-08-14T15:43:52Z")

</div>

> [@Megacannon](#):
>
> It now uses truly random numbers from [Random.org](http://Random.org)

I’m glad you mentioned that - I never knew about [random.org](http://random.org) before.

And, you’ve given me some c# code to \<del\>steal\</del\> learn from to put better random numbers in code.

I don’t think I agree (with the site’s claim) that atmospheric noise is \*truly \*random, but it might as well be.

---

<div class="post-metadata">

**Author:** ![Megacannon](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Megacannon](https://boards.straightdope.com/u/Megacannon)\
**Post date:** [August 14, 2013, 11:21pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/113 "2013-08-14T23:21:11Z")

</div>

> [@bup](#):
>
> I’m glad you mentioned that - I never knew about [random.org](http://random.org) before.

You’re very welcome.

> [@bup](#):
>
> I don’t think I agree (with the site’s claim) that atmospheric noise is \*truly \*random, but it might as well be.

Yeah, we’re not exactly talking about the “quantum physics” kind of random. But it’s definitely good enough.

---

<div class="post-metadata">

**Author:** ![PalmerEldritch](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@PalmerEldritch](https://boards.straightdope.com/u/PalmerEldritch)\
**Post date:** [August 15, 2013, 1:38am UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/114 "2013-08-15T01:38:07Z")

</div>

> [@Cartoonacy](#):
>
> There are other ways to establish something as a given without using the word “given.” Putting it in the past tense, for example.s.

Let’s play 2 games, both involve me flipping 2 fair coins and then telling you how 1 of them landed  
Game1: If both coins land heads I tell you “one of the coins landed heads”. If both coins land tails I tell you “one of the coins landed tails”. If the coins land mixed sides I pick a coin at random and tell you either “one of the coins landed heads” or “one of the coins landed tails”. I flip both coins and tell you “one of the coins landed heads”. What is the probability that both coins landed heads?

Game2: If both coins land heads I tell you “one of the coins landed heads”. If both coins land tails I flip the coins again. If the coins land mixed sides I tell you “one of the coins landed heads”. I flip both coins and tell you “one of the coins landed heads”. What is the probability that both coins landed heads?

In both games you **have been told** exactly the same information, and yet the answer to Game1 is 1/2 and the answer to Game2 is 1/3.

The reason for the different answers lies in the calculation of prior probabilities (and doesn’t involve time-travelling). In Game1 the probability that I tell you “one of the coins landed heads” is 1/2. In other words I **could have told** you “one of the coins landed tails” but I didn’t  
In Game2 the probability that I tell you “one of the coins landed heads” is 1. In other words I couldn’t have have told you any thing else - it’s a “given”.

You choose to interpret the 2 children problem as Game2, and yet you have to interpret the MHP as Game1 in order to arrive at the correct answer.

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [August 15, 2013, 2:26am UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/115 "2013-08-15T02:26:52Z")

</div>

> [@Megacannon](#):
>
> Here we go. I fixed the program and made it much better overall. It now uses truly random numbers from [Random.org](http://Random.org) and is also much more robust than before. Requires an Internet connection to play. 😛
> 
> [http://www.mediafire.com/download/c0e2tikbeah4sbf/monty.exe](http://www.mediafire.com/download/c0e2tikbeah4sbf/monty.exe)
> 
> Full disclosure code:
> 
> ```auto
> 
> using System;
> using System.Text;
> using System.Net;
> using System.IO;
> 
> namespace monty
> {
> class Program
> {
>         
> static int Main(string[] args)
> {
> int[] rand;
> rand = GetRandomNumbers(2000, 1, 3);
> 
> if (rand == null)
> return 1;
> 
> Console.WriteLine("");
> Console.WriteLine(" **************************************");
> Console.WriteLine("* Welcome to Monty *");
> Console.WriteLine(" **************************************");
> Console.WriteLine("");
> 
> bool keepPlaying = true;
> int winningDoor;
> int montysChoice;
> int usersChoice;
> double totalCount = 0;
> double winCount = 0;
> int next = 0;
> String userInput;
> 
> while (keepPlaying == true)
> {
> usersChoice = 0;
> montysChoice = 0;
> winningDoor = rand[next];
> next++;
> 
> Console.WriteLine("There are three doors. Please enter your choice (1, 2, or 3): ");
> userInput = Console.ReadLine();
> usersChoice = Convert.ToInt32(userInput);
> 
> Console.WriteLine("Monty will now pick a door of the remaining two.");
> 
> if (usersChoice == 1)
> {
> if (usersChoice != winningDoor)
> {
> if (winningDoor == 2) { montysChoice = 3; }
> else { montysChoice = 2; }
> }
> else 
> {
> montysChoice = rand[next];
> next++;
> 
> while (montysChoice == 1)
> {
> montysChoice = rand[next];
> next++;
> }
>                         
> }
> }
> else if (usersChoice == 2)
> {
> if (usersChoice != winningDoor)
> {
> if (winningDoor == 1) { montysChoice = 3; }
> else { montysChoice = 1; }
> }
> else
> {
> montysChoice = rand[next];
> next++;
> 
> while (montysChoice == 2)
> {
> montysChoice = rand[next];
> next++;
> }
> }
> }
> else //Assume user picked number 3
> {
> if (usersChoice != winningDoor)
> {
> if (winningDoor == 1) { montysChoice = 2; }
> else { montysChoice = 1; }
> }
> else 
> {
> montysChoice = rand[next];
> next++;
> 
> while (montysChoice == winningDoor)
> {
> montysChoice = rand[next];
> next++;
> }
> }
> }
> 
> Console.WriteLine("Monty has chosen door number " + montysChoice + ". And revealed it to be a dud.");
> Console.WriteLine("Do you want to switch doors? (y or n) ");
> 
> userInput = Console.ReadLine();
> 
> if (userInput == "y")
> {
> if (usersChoice == 1 && montysChoice == 2)
> usersChoice = 3;
> else if (usersChoice == 1 && montysChoice == 3)
> usersChoice = 2;
> else if (usersChoice == 2 && montysChoice == 1)
> usersChoice = 3;
> else if (usersChoice == 2 && montysChoice == 3)
> usersChoice = 1;
> else if (usersChoice == 3 && montysChoice == 1)
> usersChoice = 2;
> else if (usersChoice == 3 && montysChoice == 2)
> usersChoice = 1;
> }
> 
> if (usersChoice == winningDoor)
> { 
> Console.WriteLine("Congratulations! Door " + usersChoice + " was the winning door!");
> winCount++;
> totalCount++;
> }
> else
> { 
> Console.WriteLine("Sorry. Door " + usersChoice + " was not the winning door.");
> totalCount++;
> }
> 
> Console.WriteLine("Wins: " + winCount + " Total Games: " + totalCount + " Win %: " + winCount / totalCount);
> Console.WriteLine("Play again? (y or n) ");
> userInput = Console.ReadLine();
> 
> if (userInput == "n") { keepPlaying = false; }
> }
> 
> return 0;
> }
> 
> static int[] GetRandomNumbers(int quantity, int lowerBound, int upperBound)
> {
> Console.WriteLine("Retrieving random numbers from Random.org...");
> 
> Console.WriteLine("Checking quota...");
> bool quotaExceeded = false;
> quotaExceeded = CheckQuotaIsExceeded();
> 
> if (quotaExceeded == true)
> {
> Console.WriteLine("Quota for this IP address has been met or exceeded. Stopping.");
> int[] failure = null;
> return failure;
> }
> else
> {
> Console.WriteLine("Quota check OK.");
> }
> 
> String strRequestURL = "http://www.random.org/integers/?num=" + quantity +
> "&min=" + lowerBound + "&max=" + upperBound + "&col=1&base=10&format=plain&rnd=new";
> WebRequest webRequest = WebRequest.Create(strRequestURL);
> 
> int[] results = new int[quantity];
> 
> try
> {
> Stream objStream = webRequest.GetResponse().GetResponseStream();
> StreamReader objReader = new StreamReader(objStream);
> 
> string line = "";
> for (int i = 0; line != null && i < quantity; i++)
> {
> line = objReader.ReadLine();
> results* = Convert.ToInt32(line);
> }
> }
> catch (Exception ex)
> {
> Console.WriteLine("Retrieval of random numbers failed.");
> Console.WriteLine("Exception: " + ex.Message);
> }
> 
> Console.WriteLine("Numbers retrieved successfully.");
> 
> return results;
> }
> 
> static bool CheckQuotaIsExceeded()
> {
> String strRequestURL = "http://www.random.org/quota/?format=plain";
> WebRequest webRequest = WebRequest.Create(strRequestURL);
> 
> Stream objStream = webRequest.GetResponse().GetResponseStream();
> StreamReader objReader = new StreamReader(objStream);
> 
> String strQuota = objReader.ReadLine();
> 
> if (Convert.ToInt32(strQuota) <= 0)
> return true;
> else
> return false;
> 
> }
> }
> }
> 
> ```
> 
> PS: I didn’t write it to look pretty.

In an old Monty thread I wrote a similar short program in Java:

> [@Monty Hall problem on MythBusters](https://boards.straightdope.com/t/monty-hall-problem-on-mythbusters/604134/104):
>
> So I wrote a little program to calculate your winnings if you always switch. Writing it reveals the huge reason that this problem holds – Monty’s choice is dependent on yours… and he’s omniscient.
> 
> ```auto
> 
> int NUM_DOORS = 3;
> int ITERATIONS = 1000000;
> int winCounter = 0;
> for(int i = 0; i < ITERATIONS; i++){
> Random rand = new Random();
> int winningDoor = rand.nextInt(NUM_DOORS);
> int yourDoor = rand.nextInt(NUM_DOORS);
> int montysDoor;
> 
> if(yourDoor == winningDoor){
> montysDoor = rand.nextInt(NUM_DOORS);
> while(montysDoor == yourDoor)
> montysDoor = rand.nextInt(NUM_DOORS);
> } else {
> montysDoor = winningDoor
> }
> 
> // Because we switched doors, we win if monty won
> if(montysDoor == winningDoor){
> ++winCounter;
> }
> 
> }
> 
> ```
> 
> Here’s the thing, you have a 1/NUM\_DOORS chance of picking the winning door. Monty, being omniscient, always picks the winner if you haven’t. That’s a NUM\_DOORS-1/NUM\_DOORS chance (i.e. 2/3 in a 3 door game). What Monty is basically asking you is if you want to trust omniscience or blind luck. He ALWAYS gets the winning door if you didn’t trip on it.
> 
> Fun fact about the trials – the more doors, the better it is to switch. A game with two doors causes you to win about 50% of the time by switching (you pick a door, Monty picks the other, you switch). 3 doors is always 65-67%, but usually 66.x% (remember, I’m doing a million iterations here). If you have about 100 doors, results are usually in the 99% range. Once you get one million doors, it’s not uncommon for switching to win 100 percent of the time, though it’s usually in the upper 99 percent range.

It doesn’t let you play, but it simulates about a million games (controllable with a variable). As I say in that post: the crux is that Monty is omniscient and always picks the correct door if it’s available. As you set NUM\_DOORS to successively higher numbers, the game becomes increasingly impossible to win without switching.

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [August 15, 2013, 2:34am UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/116 "2013-08-15T02:34:09Z")

</div>

(Note that my code could be made more concise, and still be logically equivalent, but it would be less illustrative of the problem)

---

<div class="post-metadata">

**Author:** ![Irishman](https://avatars.discourse-cdn.com/v4/letter/i/b487fb/32.png) [@Irishman](https://boards.straightdope.com/u/Irishman)\
**Post date:** [August 15, 2013, 6:25pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/117 "2013-08-15T18:25:31Z")

</div>

**Jragon** , I like that approach. If you don’t pick the winning door on your first pick, the the host picks the winning door for himself. So if you want to switch with the host, you get the door he picked. That is a much clearer demonstration of why the odds are in your favor to switch.

Helping someone understand that it is the logical equivalent might still be a problem.

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [August 16, 2013, 2:08pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/118 "2013-08-16T14:08:48Z")

</div>

> [@Irishman](#):
>
> **Jragon** , I like that approach. If you don’t pick the winning door on your first pick, the the host picks the winning door for himself. So if you want to switch with the host, you get the door he picked. That is a much clearer demonstration of why the odds are in your favor to switch.
> 
> Helping someone understand that it is the logical equivalent might still be a problem.

Making the program (more or less) exactly equivalent is even really that hard. You just make an array of \<n\> doors and iterate through it, marking all the ones except the winner as “open” and selecting the winner (or a random one if the user picked the winner).

I probably should have done that as it’d be more illustrative, but it felt like overkill at the time.

---

<div class="post-metadata">

**Author:** ![Hayama](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@Hayama](https://boards.straightdope.com/u/Hayama)\
**Post date:** [August 16, 2013, 7:25pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/119 "2013-08-16T19:25:23Z")

</div>

Instead of the 3 doors of Let’s Make a Deal, how about the 30 cases for Deal or No Deal? Since you can open the million dollar case, I’m assuming the odds are based upon how many cases are left? So if you got down to the last 2 cases without eliminating the million dollar case, when they give you the option to swap cases, is it 50/50 at that point, or is your case 1/30 & the other case 29/30?

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [August 16, 2013, 7:45pm UTC](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576/120 "2013-08-16T19:45:34Z")

</div>

> [@Hayama](#):
>
> Instead of the 3 doors of Let’s Make a Deal, how about the 30 cases for Deal or No Deal? Since you can open the million dollar case, I’m assuming the odds are based upon how many cases are left? So if you got down to the last 2 cases without eliminating the million dollar case, when they give you the option to swap cases, is it 50/50 at that point, or is your case 1/30 & the other case 29/30?

My immediate intuition is that the problem is different and that the swap is 50/50. The key difference, by my reasoning, is that the Host doesn’t always pick the winning case and throw away all the others. Rather, all the cases are opened (effectively) randomly until only one remains. It’s that added element that the winning case isn’t selected omnisciently that changes the probability.

The key element that makes the Monty Hall problem work isn’t “possibilities are eliminated until only two remain” so much as “possibilities are eliminated in a systematic fashion by an entity who deliberately and knowingly ensures a certain outcome if it’s possible.”

But I’m definitely not certain and willing to be shown I’m wrong.

ETA: As I see it, in Deal or No Deal the elimination of the cases one by one only affects the buyer’s offers. The game is effectively equivalent to picking a single case out of a set of 26 if you eliminate the “buyer” portion, the switch is a red herring.

[Previous page](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576.md?page=5)

[Next page](https://boards.straightdope.com/t/lets-make-a-deal-about-a-really-really-beaten-dead-horse/663576.md?page=7)
