Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- N <- 250
- # this i value will represent the grim reaper. If it comes up, adios compadre
- i <- round(runif(1,1,N))
- j <- 0
- mort = vector("numeric") # make a length 0 vector to store results
- p <- 6
- for(l in 1:3000) {
- while(p > 3) {
- j <- j + 1
- y <- sample.int(N,p,replace=TRUE) # roll the grim reaper die
- y <- y[y==i]
- p = p + length(y)*(-1) # take his due
- if(p <= 3) {
- mort <- append(mort,j)
- j <- 0
- p <- 6
- break
- }
- }
- }
- m <- median(mort)
- cat("median value: ",m,"\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement