Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- racquetball <- function(n=100)
- for (i in 1:n) {
- score.a <- 0
- score.b <- 0
- wins.a <- 0
- wins.b <- 0
- repeat {
- serve.a <- rbinom(1,1,0.6)
- if (serve.a == 1) {
- score.a <- (score.a + 1)
- } else if (rbinom(1,1,0.5) == 1) {
- score.b <- score.b + 1
- } else {
- serve.a}
- if (score.a == 21 | score.b == 21)
- break
- }
- if ("score.a" > "score. b")
- {storage[i] <- (sum(wins.a <- wins.a + 1))}
- }
Add Comment
Please, Sign In to add comment