STAT 400University of Maryland Programming Language R Exam Practice
Question Description
# 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}
“`
# 2: Monty-Hall with Ten doors.
Repeat the Monty Hall experiment now with 10 doors. Recall the game is as follows:
Step 1: you choose one door at random.
Step 2: Monty opens 8 (out of 9 doors) that do not have the prize.
Step 3: you either switch or don’t switch.
Set up the experiment two functions “monty_10doors_noswitch” and “monty_10doors_switch” (these functions will have no input values):
“`{r}
monty_10doors_noswitch <- function(){
}
monty_10doors_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}
“`
# 3. Monty-Hall 10-doors (modified).
Consider the following modified Monty-Hall game with 10 doors.
Step 1: you choose one door at random.
Step 2: Monty opens 7 (out of 9 doors) that do not have the prize.
Step 3: you either stick with your original choice, or choose between one of the two unopened doors.
Set up the experiment two functions “monty_10doors_mod_noswitch” and “monty_10doors_mod_switch” (these functions will have no input values):
“`{r}
monty_10doors_mod_noswitch <- function(){
}
monty_10doors_mod_switch <- function(){
}
“`
Use your two functions and the replicate function to compute the empirical probablility of winning for the two experiments.
The computation of the theoretical probability in this case might not be completely obvious, however, use your empirical probability to make a guess.
“`{r}
“`
Not for submission: Play with this modified setup, for example Monty opens 6 doors at step 2 etc.
# 4. BONUS: Monty Hall with n-doors.
Repeat the Monty Hall experiment now with n doors. Recall the game is as follows:
Step 1: you choose one door at random.
Step 2: Monty opens n-2 (out of n-1 doors) that do not have the prize.
Step 3: you either switch or don’t switch.
Set up the experiment two functions “monty_10doors_noswitch” and “monty_10doors_switch” (these functions will have input value as n):
“`{r}
monty_ndoors_noswitch <- function(n){
}
monty_ndoors_switch <- function(n){
}
“`
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}
“`
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."