The
Monty Hall Problem
Statement of the Problem
The
Monty Hall problem involves a classical game show situation and is named, of course,
after Monty Hall, the long-time host of the show Let's
Make a Deal. There are three doors labeled 1, 2, and 3. A pot of gold is behind one
of the doors, while goats are behind the other two:
The rules are as follows:
The Monty Hall problem became the subject of intense controversy
because of several articles by Marilyn
Vos Savant in the Ask Marilyn column of Parade
magazine, a popular Sunday newspaper supplement. The controversy began when a
reader posed the problem in the following way:
Suppose
you're on a game show, and you're given a choice of three doors. Behind one door
is a (pot of gold); behind the others, goats. You pick a door--say No. 1--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?
Marilyn's response was that the contestant should switch doors,
claiming that there is a 1/3 chance that the gold is behind door 1, while there
is a 2/3 chance that the car is behind door 2. In two follow-up columns, Marilyn
printed a number of responses, some from academics, most of whom claimed in
angry or sarcastic tones that she was wrong and that there are equal chances
that the car is behind doors 1 or 2. Marilyn stood by her original answer and
offered additional, but non-mathematical, arguments.
Here is a version of the Monty Hall problem Play with it and see if you can answer the question.
1. Setting up
2. You pick a door
Interface and PropertiesFor the interface, you will need to download 5 pictures. You need one copy of the donkey and one of the pot of gold (above) and one each of the numbered doors (picNum1, picNum2 and picNum3) below. Just right-click and select Save Picture As from the context menu. Save them to your desktop or somewhere you can find them!
Before we start adding controls, we will add the downloaded pictures into the project resource file. If you don't know how to do this, read these instructions. Now design an interface with three picture boxes, 5 labels, 3 picture boxes and 5 buttons. Set the properties as follows:
The final interface looks like this:
Writing the Code
The following code goes behind the Door 1 picture
box.
Private Sub
picDoor1_Click(ByVal sender
As System.Object,
ByVal e As System.EventArgs)
Handles picDoor1.Click
If WinningDoor = 1 Then
picDoor2.Image = My.Resources.donkey
|
| Object | Name | Caption | Other |
| Label for displaying wins | Name = lblWins | 0 | |
| Label for displaying loses | Name = lblLoses | 0 | |
| Label "Wins" | not necessary | Win | |
| Label "Losses" | not necessary | Lose | |
| Switch Button | Name = btnKeepSwitch | Switch | |
| Run Button | Name = btnRunStop | Run | |
| Clear Button | Name = btnClear | Clear | |
| Timer (not visible) | Name = Timer1 | None | Interval = 1 |
Write the Code
The Run/Stop button controls the timer. It turns the timer on or off and also changes the caption of the RunStop button.
If Timer1.Enabled Then 'if the timer is enables
Timer1.Enabled = False 'turn it off
btnRunStop.Text = "Run" 'change the text property of the RunStop button to "Run"Else
Timer1.Enabled = True 'otherwise, turn it on
btnRunStop = "Stop" 'change the text property of the RunStop button to "Stop"End If
The Keep/Switch button determines if you are doing a switch or keep
If btnKeepSwitch.Text.Caption = "Keep" Then
btnKeepSwitch.Text.Caption = "Switch"
Else
btnKeepSwitch.Text.Caption = "Keep"
End If
The Clear button simply puts zeros in the Wins ans Losses labels
lblWin.Text = "0"
lblLoses.Text = "0"
Most of the action takes place in the timer. Every time it ticks, a game is "played" and the result tallied.
Dim PlayerWins, PlayerLoses As Integer
WinningDoor = Int(Rnd() * 3) + 1 'Random Winning Door
PlayerDoor = Int(Rnd() * 3) + 1 'Random Player DoorIf btnStrategy.Text = "Keep" Then
If WinningDoor = PlayerDoor Then
lblWin.Text = Str(Val(lblWin.Text) + 1)
Else
lblLose.Text = Str(Val(lblLose.Text) + 1)
End If
Else
If WinningDoor <> PlayerDoor Then
lblWin.Text = Str(Val(lblWin.Text) + 1)
Else
lblLose.Text = Str(Val(lblLose.Text) + 1)
End If
End If
Run a couple of thousand games with a switch strategy and several thousand with a keep strategy. Are you convinced about the correct strategy?
|
|