Created
September 26, 2022 18:15
-
-
Save diamonaj/e75cc606f1a0869d035c696b4fb9fcc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| die_rolls <- 1:6 | |
| storage <- c() | |
| for(i in 1:1000) | |
| { | |
| rolls_for_the_week <- sample(die_rolls, 7, replace = TRUE) | |
| storage[i] <- sum(rolls_for_the_week == 1) == 0 # if there's no 1, then TRUE | |
| } | |
| cat("\nthe probability of not rolling a 1 all week is estimated =", | |
| sum(storage)/1000, "\n") | |
| cat("\nthe probability of rolling at least a single 1 all week is estimated =", | |
| 1 - sum(storage)/1000, "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment