Guest User

Untitled

a guest
Dec 18th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. N <- 10000
  2. S <- sum(runif(N)<0.5)
  3. S/(S+0.5*(N-S))
  4.  
  5. N <- 10^6
  6. ballsinboxes <- c("G","G", "G","S", "S","S")
  7. selectedbox <- sample(c(1,2,3), N, replace=TRUE)
  8. selectedball <- sample(c(1,2), N, replace=TRUE)
  9. selectedcolour <- ballsinboxes[(selectedbox-1)*2 + selectedball ]
  10. othercolour <- ballsinboxes[(selectedbox-1)*2 + 3 - selectedball ]
  11. sum(selectedcolour == "G" & othercolour == "G") / sum(selectedcolour == "G")
Add Comment
Please, Sign In to add comment