Skip to content
Prev 7835 / 15274 Next

Expected lengths of streaks

About 1,000 years ago I calculated the expected length of a losing
streak by iterative simulation using rle

    trades <- sample(c("W", "L"), 1000, replace = TRUE, prob =
c("0.66", "0.33"))
    trades.rle <- rle(trades)
    tapply(trades.rle$lengths, trades.rle$values, max)

There must be other, better ways today...

    jab