On 11/30/2011 10:55 PM, Henrique Andrade wrote:
> Dear Hansl experts,
> 
> I would like to write a Hansl code but unfortunately I'm out of
> creativity :(
> I have a binary series with blocks of 0 and 1. Something like
> 
> X=(0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1).
> 
> Here are the steps I need do follow:
> 
> (1) Find the number of 1-blocks;
> (2) Calculate the average number of observations inside these blocks.
> 
> In my hypothetical example, the X series, I have two blocks, and these
> blocks have an average of 8 observations (five observations in the first
> block and eleven observations in the second block).
> 

Just a quick thought: you could take the (serial/first) difference of
your series and count the occurrences of -1, which indicates how many
times you have a 01 pattern. And each 1 in the difference indicates the
position of a 10 pattern (or vice versa, depending on whether you take
left-to-right or right-to-left differences). The position indices help
you determine how many ones you have in between, i.e. in each block.

But your problem in general does look like unpleasant details to code.

hth,
sven


Reply via email to