code: def lag1_acf(x, detrend_deg=1):
      
      mu = np.mean(x)
      a=0
      b=0
      for n in range(len(x)-1):
          a = a + (x[n]-mu)*(x[n+1]-mu)
      for n in range(len(x)):
          b=b+pow( x[n]-mu , 2 )
      return a/b
docs: Lag-1 autocorrelation function
          as defined in Riley 2004, Eqn (2)
          used by autocorr_noise_id()
          
          Parameters
          ----------
          x: numpy.array
              time-series
          Returns
          -------
          ACF: float
              Lag-1 autocorrelation for input time-series x
          
          Notes
          -----
          * a faster algorithm based on FFT might be better!?
          * numpy.corrcoeff() gives similar but not identical results.
              #c = np.corrcoef( np.array(x[:-lag]), np.array(x[lag:]) )
              #r1 = c[0,1] # lag-1 autocorrelation of x