title: python recursive vectorization with timeseries
body: <p>I have a Timeseries (s) which need to be processed recursively to get a timeseries result (res). Here is my sample code:</p>
  
  <pre><code>res=s.copy()*0  
  res[1]=k # k is a constant  
  for i in range(2,len(s)):  
      res[i]=c1*(s[i]+s[i-1])/2 +c2*res[i-1]+c3*res[i-2]
  </code></pre>
  
  <p>where c1,c2,c3 are constants. It works properly but I'd like to use vectorization and I tried with:  </p>
  
  <pre><code>res[2:]=c1*(s[2:]+s[1:-1])/2+c2*res[1:-1]+c3*res[0:-2]  
  </code></pre>
  
  <p>but I get  "ValueError: operands could not be broadcast together with shapes (1016) (1018) "<br>
  if I try with  </p>
  
  <pre><code>res=c1*(s[2:]+s[1:-1])/2+c2*res[1:-1]+c3*res[0:-2]  
  </code></pre>
  
  <p>doesn't give any error, but I don't get a correct result, because res[0] and res[1] have to be initialized before the calculation will take place.
  Is there a way to process it with vectorization?<br>
  Any help will be appreciated, thanks!</p>