Question

In: Computer Science

Using Rstudio # 1. Monty-Hall Three doors Recall the Monty-Hall game with three doors, discussed in...

Using Rstudio

# 1. Monty-Hall Three doors

Recall the Monty-Hall game with three doors, discussed in class. Run a simulation to check that the probablility of winning increases to 2/3 if we switch doors at step two.

Set up the experiment two functions "monty_3doors_noswitch" and "monty_3doors_switch" (these functions will have no input values):

```{r}
monty_3doors_noswitch <- function(){
  
}

monty_3doors_switch <- function(){
  
}

```

Use your two functions and the replicate function to compute the empirical probablility of winning for the two experiments.
Compare your answers with the actual theoretical predictions.

```{r}

```

Solutions

Expert Solution

monty3doors_no_switch.r:

monty3doors_no_switch <- function(){
  
doors = c(1,2,3) # had 3 doors
  
ch1 = sample(doors, 1) # 1st choice: pick one door at random
crct1 = sample(doors, 1) # the correct box
  
# Assume When making the second choice, you stick with the original choice and you are RIGHT
  
# let X be a binary variable that takes the value 1 if the choice is correct and 0 if incorrect
x = 0
x = ifelse(ch1 == crct1,1,0) # you stick with the original choice and you are RIGHT
x
}


no_of_Successes = replicate(1000000, monty3doors_no_switch())
prob = sum(no_of_Successes)/1000000
probability = prob
probability

Output Screenshot:

monty_3doors_switch.r:

monty_3doors_switch = function(){
  
doors = c(1,2,3) # had 3 doors
  
ch = sample(doors, 1) # 1st choice: pick one door at random
crct = sample(doors, 1) # the correct box
  
# When making the second choice, you stick with the original choice and you are WRONG.
  
# let X be a binary variable that takes the value 1 if the choice is correct and 0 if incorrect
x = 0
x = ifelse(ch != crct,1,0) # you stick with the original choice and you are WRONG.
x
}

no_of_Successes = replicate(1000000, monty_3doors_switch())
prob = sum(no_of_Successes)/1000000
probabilty = prob
prob


Output Screenshot:

Compare your answers with the actual theoretical predictions:


Related Solutions

consider the Monte Hall problem as discussed in lecture. Recall that a game show host(Monte Hall)...
consider the Monte Hall problem as discussed in lecture. Recall that a game show host(Monte Hall) gives a contest a chance to choose from three doors of which one is a new car and the other two are goats. After the contestant chooses a door, the game show host who knows what is behind all of the doors decides to open another door behind which a goat sits. The games show host. then, offers the contestant an opportunity to switch...
consider the Monte Hall problem as discussed in lecture. Recall that a game show host(Monte Hall)...
consider the Monte Hall problem as discussed in lecture. Recall that a game show host(Monte Hall) gives a contest a chance to choose from three doors of which one is a new car and the other two are goats. After the contestant chooses a door, the game show host who knows what is behind all of the doors decides to open another door behind which a goat sits. The games show host. then, offers the contestant an opportunity to switch...
consider the Monte Hall problem as discussed in lecture. Recall that a game show host(Monte Hall)...
consider the Monte Hall problem as discussed in lecture. Recall that a game show host(Monte Hall) gives a contest a chance to choose from three doors of which one is a new car and the other two are goats. After the contestant chooses a door, the game show host who knows what is behind all of the doors decides to open another door behind which a goat sits. The games show host. then, offers the contestant an opportunity to switch...
Recall the Monty Hall problem as presented in class. There are three caves, two of which...
Recall the Monty Hall problem as presented in class. There are three caves, two of which contain dragons and one of which is a hiding princess. The prince chooses a cave and a wizard (truthfully) reveals to the prince that one of the other caves has a dragon. 2 The prince now has the option to switch to the other cave (the one he didn’t choose and wasn’t revealed to have a dragon), and try his luck finding the princess...
Recall the Monty Hall problem as presented in class. There are three caves, two of which...
Recall the Monty Hall problem as presented in class. There are three caves, two of which contain dragons and one of which is a hiding princess. The prince chooses a cave and a wizard (truthfully) reveals to the prince that one of the other caves has a dragon. 2 The prince now has the option to switch to the other cave (the one he didn’t choose and wasn’t revealed to have a dragon), and try his luck finding the princess...
(a) In the Monty Hall problem with 100 doors, you pick one and Monty opens 98...
(a) In the Monty Hall problem with 100 doors, you pick one and Monty opens 98 other doors with goats. What is the probability of winning (assuming you would rather have a car than a goat) if you switch to the remaining door? Explain your answer. (b) Suppose Monte opens 98 doors without checking for cars. What is the probability that, once the doors are open, changing your choice will not change your chances of winning.
2. (Monty Hall) Suppose you are on a game show and are presented with three closed...
2. (Monty Hall) Suppose you are on a game show and are presented with three closed doors marked door 1, 2, and 3. Behind one door is a prize and behind the other two are goats. Suppose the host allows you to select one door, but the following two rules apply: • Before it is opened the host opens one of the two unselected doors that has a goat behind it. • The host then allows you to switch your...
(Monty Hall problem) Suppose you’re on a game show, and you’re given the choice of three...
(Monty Hall problem) Suppose you’re on a game show, and you’re given the choice of three doors, say Door 1, Door 2, and Door 3. Behind one door there is a car; behind the others, goats. Assume it is equally likely that the car is behind any door, i.e., P(D1) = P(D2) = P(D3). You will win whatever is behind the door you choose. (a) If you pick Door 1, what is your probability of winning the car? [2 point]...
Monty hall Problem Explain the statistical probabilities associated with the game show
Monty hall Problem Explain the statistical probabilities associated with the game show
A variance of Monty Hall Problem. Let's say I am playing a game where there are...
A variance of Monty Hall Problem. Let's say I am playing a game where there are 6 doors, there is a car behind 2 doors and there are goats behind 4 doors. I don't know what is behind the doors but I want a car. Let's say I pick a door at random, so Initially, my chances of winning a car are 1/3. But before I open my door to see if I won, the host of the game opens...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT