# Expected lengths of streaks

3 messages
Open this post in threaded view
|
Report Content as Inappropriate

## 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 -- John Bollinger, CFA, CMT www.BollingerBands.com If you advance far enough, you arrive at the beginning. _______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance-- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Expected lengths of streaks

 hi john: I'm not clear on whether you want expected value of the max length or the expected value of the length. but, if you want the latter in closed form and you know , p, the probability of sucess ( in your case , the probability of winning trade), then the number of trials before you win ( so the length would be the number of losses )  can be thought as having a geometric distribution. this distribution has expected value of (1-p)/p. and no, I definitely had to look that up because I didn't remember the formula. I'm not sure how one would handle the expected value of the max length analytically. maybe simulation is the only way but you might be able to do it faster using the analytical result above. On Tue, May 3, 2011 at 8:05 PM, BBands <[hidden email]> wrote: > 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 > -- > John Bollinger, CFA, CMT > www.BollingerBands.com > > If you advance far enough, you arrive at the beginning. > > _______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance> -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions > should go. >         [[alternative HTML version deleted]] _______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance-- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.