daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Aug 30th, 2017 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. z <- c()
  2.  
  3. for(j in 1:10000) {
  4. x <- c()
  5.   y <- c()
  6.  
  7.   for(i in 1:100) {
  8.  
  9.     y <- c(y, rbinom(1, 1, .5))
  10.  
  11.     if (i > 3) {
  12.  
  13.       if (y[i-1] == 1 & y[i-2] == 1 & y[i-3] == 1) {
  14.  
  15.         if (y[i] == 1) {
  16.  
  17.           x <- c(x,1)
  18.  
  19.         } else {
  20.  
  21.           x <- c(x,0)
  22.        
  23.         }
  24.  
  25.       }
  26.  
  27.     }
  28.    
  29.   }
  30.    
  31.    if (length(x) > 0) {
  32.    z <- c(z, sample(x,1))
  33.    }
  34. }
  35.  
  36. mean(z)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top