title: Arnaud Legoux Moving Average and numpy
body: <p>I'd like to write the vectored version of code that calculates Arnaud Legoux Moving Average using NumPy (or Pandas). Could you help me with this, please? Thanks.</p>
  
  <p>Non-vectored version looks like following (see below). </p>
  
  <pre><code>def NPALMA(pnp_array, **kwargs) :
      '''
      ALMA - Arnaud Legoux Moving Average,
      http://www.financial-hacker.com/trend-delusion-or-reality/
      https://github.com/darwinsys/Trading_Strategies/blob/master/ML/Features.py
      '''
      length = kwargs['length']
      # just some number (6.0 is useful)
      sigma = kwargs['sigma']
      # sensisitivity (close to 1) or smoothness (close to 0)
      offset = kwargs['offset']
  
      asize = length - 1
      m = offset * asize
      s = length  / sigma
      dss = 2 * s * s
  
      alma = np.zeros(pnp_array.shape)
      wtd_sum = np.zeros(pnp_array.shape)
  
      for l in range(len(pnp_array)):
          if l &gt;= asize:
              for i in range(length):
                  im = i - m
                  wtd = np.exp( -(im * im) / dss)
                  alma[l] += pnp_array[l - length + i] * wtd
                  wtd_sum[l] += wtd
              alma[l] = alma[l] / wtd_sum[l]
  
      return alma
  </code></pre>