code: def _moving_average(data, wind_size=3):
      
  
      wind_size = int(wind_size)
      ret = numpy.cumsum(data, dtype=float)
      ret[wind_size:] = ret[wind_size:] - ret[:-wind_size]
      return numpy.concatenate((numpy.zeros(wind_size - 1), ret[wind_size - 1:] / wind_size))
docs: -----
      Brief
      -----
      Application of a moving average filter for signal smoothing.
  
      -----------
      Description
      -----------
      In certain situations it will be interesting to simplify a signal, particularly in cases where
      some events with a random nature take place (the random nature of EMG activation periods is
      a good example).
  
      One possible simplification procedure consists in smoothing the signal in order to obtain
      only an "envelope". With this methodology the analysis is mainly centered on seeing patterns
      in data and excluding noise or rapid events [1].
  
      The simplification can be achieved by segmenting the time series in multiple windows and
      from each window an average value of all the samples that it contains will be determined
      (dividing the sum of all sample values by the window size).
  
      A quick and efficient implementation (chosen in biosignalsnotebooks package) of the moving window
      methodology is through a cumulative sum array.
  
      [1] https://en.wikipedia.org/wiki/Smoothing
  
      ---------
      Parameters
      ----------
      data : list
          List of signal samples.
      wind_size : int
          Number of samples inside the moving average window (a bigger value implies a smoother
          output signal).
  
      Returns
      -------
      out : numpy array
          Array that contains the samples of the smoothed signal.