Prove the Monty Hall Problem (via Simulation)!

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

60 Replies - 17477 Views - Last Post: 16 June 2014 - 07:20 AM

#1 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4498
  • View blog
  • Posts: 7,850
  • Joined: 08-June 10

Prove the Monty Hall Problem (via Simulation)!

Post icon  Posted 19 September 2012 - 12:45 PM

Wiki link: Monty Hall Problem

Quote

Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1 [but the door is not opened], and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?


Answer:
Spoiler


Some of you yourselves may not believe the predicted result.

Here's the interesting bit from the article:

Quote

Many readers refused to believe...After the Monty Hall problem appeared in Parade, approximately 10,000 readers, including nearly 1,000 with PhDs, wrote to the magazine claiming that vos Savant was wrong (Tierney 1991). Even when given explanations, simulations, and formal mathematical proofs, many people still do not accept...the best strategy. According to the French magazine Le Figaro Magazine, Paul Erdős, the most prolifically published mathematician of modern times, found it very hard to believe the result of his own calculations, and admitted he was not fully convinced until a simple computer simulation confirmed the predicted result.


So, let's write our own simulations and prove or disprove this! Your program can be as simple or complex as you feel necessary, as long as it proves your theory. It must incorporate these key points:

  • There are three prizes, one good and two bad.
  • After one prize is chosen by the player (at random, without knowing what they have), one bad prize is removed from the left-over choices.
  • This is where the simulations must diverge. You must show what happens when the contestant keeps the prize they've already chosen, and what happens when they switch.
  • Repetition is key. Small sample runs prove nothing. Write your program so that it proves your hypothesis, or at least strongly suggests it with data.


This is posted in the C# section, but I welcome any language submission.

Please post your answer code in spoilers. I'll post mine once we get a few entries.

Edit for clarity: our goal here is to actually write a program to perform the simulation. I know that this is a simple problem to prove with math, but the fun is in writing the code to prove that. I've updated the title to make this more clear.

Is This A Good Question/Topic? 3
  • +

Replies To: Prove the Monty Hall Problem (via Simulation)!

#2 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7806
  • View blog
  • Posts: 13,200
  • Joined: 19-March 11

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 12:56 PM

The proof has already been provided.

To look at it another way, imagine that there are 100 doors. Now, after you pick one, the host opens 98 doors, leaving one closed. What are the odds that you picked the right door the first time? 1/100. Therefore, what are the odds that the prize is behind the remaining closed door? 99/100.

The same logic holds when N = 3.

Another way to convince yourself is to imagine that you get to select two doors of four - if you have a winner, you keep it. Now the host opens one door each from the selected and the unselected doors. Does switching help you in this case?


The challenge, if you want to be particular about it, is not to prove, but to illustrate the provided proof.

This post has been edited by jon.kiparsky: 19 September 2012 - 01:02 PM

Was This Post Helpful? 0
  • +
  • -

#3 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4498
  • View blog
  • Posts: 7,850
  • Joined: 08-June 10

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 12:59 PM

Completely true. I suppose I should have made it more clear that this is a programming exercise to prove what math can and has already proven with an actual simulation.
Was This Post Helpful? 0
  • +
  • -

#4 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7806
  • View blog
  • Posts: 13,200
  • Joined: 19-March 11

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 01:03 PM

Just me being nitpicky, don't mind me. Expect a scala solution this evening, since that's what I'm learning now. :)
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,789
  • Joined: 12-June 08

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 01:08 PM

Heh.. I was going to post a link to Mythbusters and declare myself done. Now I gotta write up some code that links to, and plays, the mythbusters video to win!

;)
Was This Post Helpful? 1
  • +
  • -

#6 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7806
  • View blog
  • Posts: 13,200
  • Joined: 19-March 11

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 01:12 PM

I'm going to deliver actual goats and cars to the user. You're going to have to beat that, buddy.
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,789
  • Joined: 12-June 08

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 01:21 PM

Pffssh.. what evs..

Who would want your Bostonian sourced gutter goats anyways with their broad-a bleats and reeking of Belichick's musk?

I, on the other hand, have organically grown petite lap goats that also dress up in AT-AT costumes, bleat with an accent neutral voice of an angel, and are hypoallergenic.
Was This Post Helpful? 0
  • +
  • -

#8 CodeGrappler  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 41
  • View blog
  • Posts: 120
  • Joined: 29-November 10

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 01:32 PM

View Postmodi123_1, on 19 September 2012 - 01:21 PM, said:

Pffssh.. what evs..

Who would want your Bostonian sourced gutter goats anyways with their broad-a bleats and reeking of Belichick's musk?

I, on the other hand, have organically grown petite lap goats that also dress up in AT-AT costumes, bleat with an accent neutral voice of an angel, and are hypoallergenic.


But you don't have cars...
Was This Post Helpful? 2
  • +
  • -

#9 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,789
  • Joined: 12-June 08

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 01:39 PM

My petite lap goats believe in being green - that's why some dress up as AT-ATs - as a simulation of a car without the unneeded carbon foot print.
Was This Post Helpful? 0
  • +
  • -

#10 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7806
  • View blog
  • Posts: 13,200
  • Joined: 19-March 11

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 01:52 PM

Not much meat on one of them petite lap coats, is there?
Was This Post Helpful? 0
  • +
  • -

#11 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3000
  • View blog
  • Posts: 10,393
  • Joined: 08-August 08

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 02:27 PM

Too soon?
Spoiler

This post has been edited by CTphpnwb: 19 September 2012 - 02:29 PM

Was This Post Helpful? 2
  • +
  • -

#12 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4498
  • View blog
  • Posts: 7,850
  • Joined: 08-June 10

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 02:47 PM

Definitely not too soon.

Here was my solution:

Spoiler

Was This Post Helpful? 1
  • +
  • -

#13 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 05:14 PM

Sorry, been working in Python all day.
Spoiler


Wondering if any clever LINQ person could make that happen in C#, since it looks rather LINQy.
Was This Post Helpful? 3
  • +
  • -

#14 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7806
  • View blog
  • Posts: 13,200
  • Joined: 19-March 11

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 19 September 2012 - 11:50 PM

Here's a pretty straightforward python implementation. Too tired to try to do it in scala tonight.


Spoiler


EDIT: Due to technical difficulties, this version does not deliver goats and cars. However, if my kickstarter comes through I'll be developing my e-goat delivery system and that little glitch will be addressed.

This post has been edited by jon.kiparsky: 20 September 2012 - 11:54 AM

Was This Post Helpful? 3
  • +
  • -

#15 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,056
  • Joined: 28-December 10

Re: Prove the Monty Hall Problem (via Simulation)!

Posted 20 September 2012 - 01:24 AM

I'm not sure if what I did is correct, but here's something from Python:

Spoiler


100 runs
Spoiler


1000 runs
Spoiler


A million ways
Spoiler


Yeah I know, the code needs improvement lots. I hope one day I can do something like baavgai's on Python.
From the figures, yeah I think the Monty Hall problem proves itself... unless if what I did is completely off. There there. ^^
Was This Post Helpful? 2
  • +
  • -

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »