शुरू करेंमुफ़्त में शुरू करें

Win probability with "stick"

Let's write some code to simulate the Monty Hall game show. In this exercise, we will have the contestant choose Door #1, "stick" every time, and find the relative frequency of winning after 10000 iterations of the game.

First, we will code just one iteration. Then, we will incorporate this into a for loop to run the process repeatedly in order to obtain a simulated estimate of the true win probability, using the idea of a counter we discussed previously.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Probability Puzzles in R

पाठ्यक्रम देखें

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

set.seed(1)
doors <- c(1,2,3)

# Randomly select one of the doors to have the prize
 prize <- sample(x = ___, size = ___)
 initial_choice <- 1

# Check if the initial choice equals the prize
 if(___){
  print("The initial choice was correct!")
 }

print(prize)
कोड संपादित करें और चलाएँ