Guest User

Untitled

a guest
Nov 20th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. racquetball <- function(n=100)
  2.  
  3. for (i in 1:n) {
  4. score.a <- 0
  5. score.b <- 0
  6. wins.a <- 0
  7. wins.b <- 0
  8.  
  9. repeat {
  10. serve.a <- rbinom(1,1,0.6)
  11.  
  12. if (serve.a == 1) {
  13. score.a <- (score.a + 1)
  14.  
  15. } else if (rbinom(1,1,0.5) == 1) {
  16. score.b <- score.b + 1
  17.  
  18. } else {
  19. serve.a}
  20.  
  21. if (score.a == 21 | score.b == 21)
  22. break
  23. }
  24. if ("score.a" > "score. b")
  25. {storage[i] <- (sum(wins.a <- wins.a + 1))}
  26. }
Add Comment
Please, Sign In to add comment