I'm trying to do simulation of a sequence, which is of length N (varies between 10k and 3M) represented by a vector which has n 1's and s 0's where N = n+s.
I'd like to reduce this to a vector on the form c( 137, 278, 21271, 124162, ... ) where the numbers are the number of consecutive 1's in the original vector. Since I need to do this ~100,000 times for the simulation I'm doing I'm looking for as efficient a method as possible!
Thanks!
Martin