Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- z <- c()
- for(j in 1:10000) {
- x <- c()
- y <- c()
- for(i in 1:100) {
- y <- c(y, rbinom(1, 1, .5))
- if (i > 3) {
- if (y[i-1] == 1 & y[i-2] == 1 & y[i-3] == 1) {
- if (y[i] == 1) {
- x <- c(x,1)
- } else {
- x <- c(x,0)
- }
- }
- }
- }
- if (length(x) > 0) {
- z <- c(z, sample(x,1))
- }
- }
- mean(z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement