code: def get_auto_correlation(chain, lag):
      r
      normalized_chain = chain - np.mean(chain, dtype=np.float64)
      lagged_mean = np.mean(normalized_chain[:len(chain) - lag] * normalized_chain[lag:], dtype=np.float64)
      return lagged_mean / np.var(chain, dtype=np.float64)
docs: r"""Estimates the auto correlation for the given chain (1d vector) with the given lag.
  
      Given a lag :math:`k`, the auto correlation coefficient :math:`\rho_{k}` is estimated as:
  
      .. math::
  
          \hat{\rho}_{k} = \frac{E[(X_{t} - \mu)(X_{t + k} - \mu)]}{\sigma^{2}}
  
      Please note that this equation only works for lags :math:`k < n` where :math:`n` is the number of samples in
      the chain.
  
      Args:
          chain (ndarray): the vector with the samples
          lag (int): the lag to use in the autocorrelation computation
  
      Returns:
          float: the autocorrelation with the given lag