Monty Hall w/ 4 doors in Maple

In summary, the conversation is about setting up a Monty Hall simulation problem with 4 doors and the process for simulating it using a procedure in Maple. The user is having trouble with their code and is seeking help to identify any mistakes. They are advised to replace "rendomize()" with "randomize()" in their code.
  • #1
fluffik
2
0
Hi, Iam a new user of Maple and having hard time to figure out what Iam doing wrong.
I need to set up Monty Hall simulation problem with 4 doors. Monty will open door twice and give opportunity to the player to switch the door or not. That's what I came up with. Could anyone point out my mistakes. Thank you

restart;
with(Statistics):
rendomize():
MontyHall:=proc(N::posint,{switch::truefalse:=false})
# Simulations for the 4-door Monty Hall problem.
N is the # of trials.
Returns the number of trials the player wins.
local
wins:=0,
Car,# the door with the Car behind it(1..4).
Montys1stDoor, # The door that Monty reveals first(1..4).
Montys2ndDoor, # The door that Monty reveals second(1..3).
Players1stDoor, # The door the player picks first.
Players2ndDoor, # The door the player picks second.
Players3rdDoor, # The door the player picks third.
Doors:={1,2,3,4};
switch:=switch1,switch2;
rand4:=rand(1..4),rand3:=rand(1..3),rand2:=rand(1..2);

to N do
Car:=rand4();
Players1stDoor:=rand4();
if Players1stDoor=Car then
Montys1stDoor:=(Doors minus{Car})[rand3()]
else
Montys1stDoor:=(Doors minus{Car,Players1stDoor})[]
end if;

if switch1 then
Players2ndDoor:=(Doors minus{Montys1stDoor,Players1stDoor})[rand2()]
else
Players2ndDoor:=Players1stDoor
end if;

if Players2ndDoor=Car then
Montys2ndDoor:=(Doors minus{Car,Montys1stDoor})[rand2()]
else
Montys2ndDoor:=(Doors minus{Car,Montys1stDoor,Players2ndDoor})[]
end if;

if switch2 then
Players3rdDoor:=(Doors-{Montys1stDoor,Montys2ndDoor,Players2ndDoor})[]
else
Players3rdDoor:=Players2ndDoor
end if;

if Players3rdDoor=Car then
wins:=wins+1;
end if
end do;
wins
end proc:
 
Physics news on Phys.org
  • #2
Have you tried replacing rendomize() by randomize()?
 
  • #3
Yes, thank you!
 

What is the Monty Hall problem with 4 doors in Maple?

The Monty Hall problem is a famous probability puzzle that originated from the TV show "Let's Make a Deal". In this version, there are 4 doors instead of 3, and the game takes place in the fictional town of Maple.

What is the premise of the Monty Hall problem?

The Monty Hall problem involves a game show host, Monty Hall, presenting a player with 4 doors, one of which has a prize behind it. The player chooses a door, and then Monty reveals one of the other doors that does not have the prize. The player is then given the option to switch their initial choice for the remaining unopened door, with the assumption that the player wants to win the prize.

Why is the Monty Hall problem considered a paradox?

The Monty Hall problem is considered a paradox because the answer to the problem seems counterintuitive and goes against our intuition and common sense. Many people believe that the player's odds of winning would be the same regardless of whether they switch or stay with their initial choice, but this is not the case.

What is the optimal strategy for winning the Monty Hall problem with 4 doors in Maple?

The optimal strategy for winning the Monty Hall problem with 4 doors in Maple is to always switch your initial choice. This strategy gives the player a 75% chance of winning, compared to a 25% chance if they choose to stay with their initial choice. This can be proven mathematically and has been demonstrated through numerous simulations and experiments.

What are the real-world applications of the Monty Hall problem?

The Monty Hall problem has real-world applications in fields such as game theory, statistics, and decision making. It can also be used to demonstrate the importance of understanding probabilities and making informed decisions based on logical reasoning, rather than relying on intuition.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
15
Views
1K
Replies
12
Views
1K
  • General Math
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
907
  • Set Theory, Logic, Probability, Statistics
7
Replies
212
Views
11K
Replies
5
Views
3K
  • General Math
Replies
30
Views
3K
  • Programming and Computer Science
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
Back
Top