Results 1 to 6 of 6

Thread: [WPF/VB.Net] Monty Hall Puzzle demo

  1. #1

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    [WPF/VB.Net] Monty Hall Puzzle demo

    I stumbled upon something rather interesting on YouTube yesterday called the Monty Hall Problem. Imagine you were given 3 doors from which you can choose one. Behind one of these doors is a prize but you do not know which door it's behind so you must guess. This means you have a 1 in 3 chance of choosing the correct one. Now lets say you are asked to choose a door and after making that choice, one of the doors which do not host the prize is revealed to you. This leaves you with the door you chose and another door. Now, you are offered the chance to either change your choice or stay with the choice you made, what would you do?

    This is where it got interesting. Everyone's first instinct, including mine was to believe the odds of picking the correct answer goes down from 1 in 3 to a 1 in 2 chance. Better odds than before but it feels like 50/50 whether or not you change your choice after the false door was revealed. It turns out that the best option is to actually change your choice. This puzzle fooled a lot of very intelligent and highly educated people. I'm not going to bore you with the details of all this and the technical details behind this puzzle. You can check out video yourself where it's all explained:-


    Nonetheless, I found this puzzle rather intriguing and I didn't really understand it at first so I wrote a small WPF application to actually test whether always choosing a different door after a reveal of false doors really does improve the odds, which of course they absolutely did. The application even allows you to go beyond just 3 doors which will very quickly give you a solid intuition for why this puzzle works the way it does.

    See the attachment for the application. You will need Visual Studio 2022 to open it.

    Here is a small video of me demonstrating how to use the application.


    Have fun.
    Attached Files Attached Files
    Last edited by Niya; Mar 17th, 2022 at 06:40 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,092

    Re: [WPF/VB.Net] Monty Hall Puzzle demo

    Quote Originally Posted by Niya View Post
    . . . so I wrote a small WPF application to actually test whether always choosing a different door after a reveal of false doors really does improve the odds, which of course they absolutely did.
    What you've done is called Monte Carlo simulation and is a viable algorithm from CS -- I've used this in programming competition in my high-school years :-))

    I've recently re-watched 21 movie and solving the Monty Hall Problem was how the main character was picked up by his math teacher for the crew to hit the Vegas casinos.

    My IQ is obvious not as high as Savant's (though not too bad either) so I couldn't figure out the odds without pen and a paper on first occasion with the problem. Some Nobel Prize winners failed too so I don't feel too bad about it at all. . . :-))

    cheers,
    </wqw>

  3. #3
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,106

    Re: [WPF/VB.Net] Monty Hall Puzzle demo

    Quote Originally Posted by Niya View Post
    Everyone's first instinct, including mine was to believe the odds of picking the correct answer goes down from 1 in 3 to a 1 in 2 chance.
    Meh, I'm sure there are plenty of people who don't understand odds that wouldn't even be able to get that far.

    A long time ago I had a discussion with a friend about this, who was convinced it was 1/2. And what made it click for him was me saying, what if instead of opening a losing door, he simply said "Would you like to switch from your 1 selected to the other 2 doors". Now it is clear that your odds of winning are 2/3 of the time. And you know that one of them obviously is a losing door, so him revealing that losing door "ahead of your switch to the other 2 doors" doesn't change anything.

  4. #4
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,106

    Re: [WPF/VB.Net] Monty Hall Puzzle demo

    Another way to examine it is to simply keep track of the odds. We know, at any point in the game, the odds of winning + the odds of losing must equal 1.

    When the initial selection is made, the odds of winning are 1/3. We also know that of the two unselected doors, one of them is guaranteed to be a loser. So, unless we are presented with new information, our odds of winning remain at 1/3. The fact that a non-selected losing door is revealed to be a losing door isn't new information, so after it is opened our odds of winning with our initially selected door remain at 1/3. So the odds of winning by switching must be 2/3, since the combined odds must equal 1, and "staying or switching" are the only two options.

  5. #5
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: [WPF/VB.Net] Monty Hall Puzzle demo

    Quote Originally Posted by OptionBase1 View Post
    Meh, I'm sure there are plenty of people who don't understand odds that wouldn't even be able to get that far.

    A long time ago I had a discussion with a friend about this, who was convinced it was 1/2. And what made it click for him was me saying, what if instead of opening a losing door, he simply said "Would you like to switch from your 1 selected to the other 2 doors". Now it is clear that your odds of winning are 2/3 of the time. And you know that one of them obviously is a losing door, so him revealing that losing door "ahead of your switch to the other 2 doors" doesn't change anything.
    Yeah, I used the same example logic when the question came up among some friends at lunch in high school nearly fifty years ago. I also went to the one door in a hundred example when it still didn't make sense to someone, i.e. pick one door and then either keep the door you picked or switch to the other 99, which would you choose.
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  6. #6

    Thread Starter
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: [WPF/VB.Net] Monty Hall Puzzle demo

    Quote Originally Posted by wqweto View Post
    What you've done is called Monte Carlo simulation and is a viable algorithm from CS -- I've used this in programming competition in my high-school years :-))
    Wow. I had no idea that this existed in the realm of the study of probability. Now you have me thinking about all the computation problems I encountered in my life that I could not find a solution for using normal algebraic math. I find this very fascinating.

    Quote Originally Posted by wqweto View Post
    Some Nobel Prize winners failed too so I don't feel too bad about it at all. . . :-))
    Quote Originally Posted by OptionBase1 View Post
    Meh, I'm sure there are plenty of people who don't understand odds that wouldn't even be able to get that far.

    A long time ago I had a discussion with a friend about this, who was convinced it was 1/2.
    What I found so fascinating about this problem is how easy it is for even smartest of us to jump to the wrong conclusion. It reveals so clearly how much of our default intuitions about probability is so wrong. It may even explain why gambling is popular enough to generate billions in revenue worldwide. It is no secret that casinos and other facilitators of gambling cultivate odds that favor them over their patrons, yet despite the wealth of information on this, you can find no shortage of people willing to throw away enormous amounts trying to "beat the house". I think we humans are just bad at probability.

    Quote Originally Posted by passel View Post
    I also went to the one door in a hundred example when it still didn't make sense to someone, i.e. pick one door and then either keep the door you picked or switch to the other 99, which would you choose.
    This is when it really clicked for me as well. That's why I designed the application such that you can put as many doors as you like, a hundred, a thousand. I think it's the best way to illustrate visually and mechanically why switching is the better choice.

    Quote Originally Posted by OptionBase1 View Post
    Another way to examine it is to simply keep track of the odds. We know, at any point in the game, the odds of winning + the odds of losing must equal 1.

    When the initial selection is made, the odds of winning are 1/3. We also know that of the two unselected doors, one of them is guaranteed to be a loser. So, unless we are presented with new information, our odds of winning remain at 1/3. The fact that a non-selected losing door is revealed to be a losing door isn't new information, so after it is opened our odds of winning with our initially selected door remain at 1/3. So the odds of winning by switching must be 2/3, since the combined odds must equal 1, and "staying or switching" are the only two options.
    This is a nice way of looking it at. I never thought about it like this.

    Quote Originally Posted by OptionBase1 View Post
    And what made it click for him was me saying, what if instead of opening a losing door, he simply said "Would you like to switch from your 1 selected to the other 2 doors". Now it is clear that your odds of winning are 2/3 of the time. And you know that one of them obviously is a losing door, so him revealing that losing door "ahead of your switch to the other 2 doors" doesn't change anything.
    Ah yes. This is clever too. A good way to explain it to the most stubborn of laymen. I don't think I can think of a better way to explain it to a layman than this.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width