To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example aims to prove the Monty Hall Paradox using LabVIEW to automate a large sample size.
Description
The Monty Hall Paradox is a weird and wonderful statistical conundrum, which seems to defy the laws of mathematics. Having struggled to get my head around the problem, I created a LabVIEW application that definitively proves the theory.
Requirements
Steps to Implement or Execute Code
Additional Information or References
The Monty Hall Paradox:
You are a contestant on a TV game show. The game show host, complete with perfectly coiffed hair and dazzlingly white smile, is stood in front of three closed doors. Behind these doors are one luxury sports car and two goats. Assuming that you would rather win a new car than a new goat, you are tasked with guessing which door hides the car.
No skill required - this is a game of pure chance.
You make your choice. At this moment, your chances of winning the car are 1 in 3.
But here’s the curve ball, knowing the location of the car, the host opens one of the remaining doors to reveal a goat. He then offers you the opportunity to switch your choice for the other remaining closed door.
Do you take him up on the offer? What is the probability of winning the car if you switch your initial choice?
"Still 33%, right?"
Wrong! Only two closed doors remain. One must hide the car! Please try again.
"Ahhh, of course! So, statistically speaking, switching doors will not change my likelihood of winning the car. Either door now has a 50% chance of winning!"
Wrong again! Sticking with your original choice still gives you a 33% chance of winning... but changing your mind will DOUBLE your chances of winning.
The code:
This app allows you to play the afformentioned game, while LabVIEW tracks your win/lose statistics. I would recommend downloading the code (at the bottom of the page) and playing a few games yourself - thereby familiarising yourself with the flow and, more importantly, the Monty Hall Paradox.
Once you have played a few rounds, click the “prove it” button. LabVIEW will keep track of the win percentage as it automatically plays a statistically significant number of games for you (specifically, 100,000 games)
All you have to do is select whether you want LabVIEW to always stick or always switch.
Additional Information:
The application was developed with a number of interesting coding techniques.
The LabVIEW Picture Control is used for intuitive player feedback
A custom, event based dialog box provides the prove it! window
Custom Function Global Variables (FGV) allows the app track game statistics using an uninitialised shift register
The app is architected around the flexible/scalable state-machine design pattern.
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Would you be able to post a copy that could open in LV 2012?
Thanks for your interest JLHaworth!
I have just posted a 2012 version. Enjoy!
Would you be able to post a copy that could open in LV 2011?