LoslegenKostenlos loslegen

Simulate probability for a given set of five years

Now, let's use the check_for_five function from the previous question to simulate 10000 iterations of five years to get an idea of how rare Ronnie Bardah's feat of five consecutive cashes was. Again, we will assume a total of 6000 players, of which 10%, or 600 of them, will cash each year.

Diese Übung ist Teil des Kurses

Probability Puzzles in R

Kurs anzeigen

Anleitung zur Übung

  • Create a matrix of the results of who cashed for each of the five years, keeping in mind that there are assumed to be 6000 total players, and 600 of them will cash.
  • Fill in the condition to see if any player cashed in all five years.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

players <- c(1:6000)
count <- 0

for(i in 1:10000){
  # Create matrix of cashing players
  cashes <- ___
  # Check for five time winners
  if(___){
    count <- count + 1
  }
}

print(count/10000)
Code bearbeiten und ausführen