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

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

    summary(x)
    quantile(x, c(0.5, 0.8, 0.9)) 

    > summary(x)
       Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
        0.0    62.0   149.0   216.2   300.0  1902.0
    > quantile(x, c(0.5, 0.8, 0.9))
    50% 80% 90%
    149 350 495
A simple simulation. Run 10K times. Count the number of times it takes for three dice to add up 18.

The numbers very much agree with you. The median is 149. The 90th is 495 in the simulation, which is close enough to 496. There is very much a long tail in the data. So, the median and the average will not be the same. Is it a coincidence that mean is a 216?



No, I don't think this is a coincidence, but I'm not completely confident in saying that.

Thinking about it doesn't make me feel like I'm solving a maths problem. I start stacking ideas and concepts in a way which makes me feel like I'm overlaying them in a way which is incorrect.

It makes me feel like I'm solving a riddle, which hints to me that maybe it's actually a question of semantics and definitions rather than a maths problem.




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

Search: