code: def moving_statistic(values, statistic, size, start=0, stop=None, step=None, **kwargs):
      
  
      windows = index_windows(values, size, start, stop, step)
  
      # setup output
      out = np.array([statistic(values[i:j], **kwargs) for i, j in windows])
  
      return out
docs: Calculate a statistic in a moving window over `values`.
  
      Parameters
      ----------
  
      values : array_like
          The data to summarise.
      statistic : function
          The statistic to compute within each window.
      size : int
          The window size (number of values).
      start : int, optional
          The index at which to start.
      stop : int, optional
          The index at which to stop.
      step : int, optional
          The distance between start positions of windows. If not given,
          defaults to the window size, i.e., non-overlapping windows.
      kwargs
          Additional keyword arguments are passed through to the `statistic`
          function.
  
      Returns
      -------
  
      out : ndarray, shape (n_windows,)
  
      Examples
      --------
  
      >>> import allel
      >>> values = [2, 5, 8, 16]
      >>> allel.moving_statistic(values, np.sum, size=2)
      array([ 7, 24])
      >>> allel.moving_statistic(values, np.sum, size=2, step=1)
      array([ 7, 13, 24])