80.4k views
2 votes
Run a Monte Carlo simulation on this vector representing the countries of the 8 runners in this race:

runners <- c("Jamaica", "Jamaica", "Jamaica", "USA", "Ecuador", "Netherlands", "France", "South Africa")


For each iteration of the Monte Carlo simulation, within a replicate() loop, select 3 runners representing the 3 medalists and check whether they are all from Jamaica. Repeat this simulation 10,000 times. Set the seed to 1 before running the loop.

1 Answer

3 votes

Answer:

Step-by-step explanation:

# Run Monte Carlo 10k

B <- 10000

results <- replicate(B, {

winners <- sample(runners, 3)

(winners[1] %in% "Jamaica" & winners[2] %in% "Jamaica" & winners[3] %in% "Jamaica")

})

mean(results)

User AlienKevin
by
5.6k points