Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    runs <- 100000
    x <- vector(mode = "numeric", length = runs)
    for (i in 1:runs){
      while (sum(sample(1:8, size = 3, replace = TRUE)) != 24){
        x[i] <- x[i] + 1
      }
    }

    summary(x)
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
      0.0   146.0   353.0   511.8   708.0  5112.0 

    quantile(x, c(0.5, 0.8, 0.9))
     50%  80%  90% 
     353  824 1187
Strangely enough the mean agrees. The other ntiles are off a bit, but that's randomness for you.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: