title: How to vectorize process of spltting vector
body: <p>I have a vector of numbers (here random). I'd like to calculate the consecutive relation of something (here means to clarify example) on the left and right side of each number in a vector.</p>
  
  <p>Here is a procedural example. I'm interested in the vectorized form.</p>
  
  <pre class="lang-py prettyprint-override"><code>from numpy.random import rand
  import numpy as np
  numbers = rand(40)
  
  k=np.zeros(numbers.shape)
  for i in range(*numbers.shape):
       k[i]=np.mean(numbers[:i])/np.mean(numbers[i:])
  </code></pre>
  
  <p>This example will return nan in the first iteration but it is not a problem now.</p>