original_docstring: 
      Compute/plot ACF of Chi^2 residuals to test model
      
      Note: x, y, and yerr must by astropy Quantities with units!
      x: time [astropy unit quantity]
      y: data [astropy unit quantity]
      gp: celerite GuassianProccess object
      samples: celerite samples array
      plot: whether or not to plot ACF(Chi^2) [bool]
      
      returns: Ljung-Box test p-value at maxlag
      
docstring: Compute/plot ACF of Chi^2 residuals to test model
  Note: x, y, and yerr must by astropy Quantities with units.
  
  Ljung-Box test p-value at maxlag
docstring_tokens: Compute / plot ACF of Chi^2 residuals to test model Note : x y and yerr must by astropy Quantities with units . Ljung - Box test p - value at maxlag
code: def plot_acf_res(x, y, gp, samples, plot=True):
      """
      Compute/plot ACF of Chi^2 residuals to test model
      
      Note: x, y, and yerr must by astropy Quantities with units!
      x: time [astropy unit quantity]
      y: data [astropy unit quantity]
      gp: celerite GuassianProccess object
      samples: celerite samples array
      plot: whether or not to plot ACF(Chi^2) [bool]
      
      returns: Ljung-Box test p-value at maxlag
      """
      
      import statsmodels.api as sm
      
      s = np.median(samples, axis=0)
      gp.set_parameter_vector(s)
      
      kernel = gp.kernel
      
      mu, var = gp.predict(y.value, x.value, return_var=False)
      
      res2 = (mu - y.value)**2
          
      # Plot auto-correlation function (ACF) of chi^2 residuals
      acf, ci, qstat, pvals = sm.tsa.stattools.acf(res2 - np.mean(res2), qstat=True, alpha=0.05)
      
      if plot:
          sm.graphics.tsa.plot_acf(res2 - np.mean(res2))
      
      """
      lags, c, l, b = axs[1,1].acorr(res2 - np.mean(res2), maxlags=None, lw=2, color='k')
      maxlag = (len(lags)-2)/2
      # White noise
      wnoise_upper = 1.96/np.sqrt(len(x))
      wnoise_lower = -1.96/np.sqrt(len(x))
      ax.fill_between([0, maxlag], wnoise_upper, wnoise_lower, facecolor='lightgrey')
      ax.set_ylabel(r'ACF $\chi^2$', fontsize=18)
      ax.set_xlabel(r'Time Lag (days)', fontsize=18)
      ax.set_xlim(0, maxlag)
      ax.tick_params('both', labelsize=16)
      """
  
      return pvals[-1]
code_tokens: def plot_acf_res ( x , y , gp , samples , plot = True ) : import statsmodels . api as sm s = np . median ( samples , axis = 0 ) gp . set_parameter_vector ( s ) kernel = gp . kernel mu , var = gp . predict ( y . value , x . value , return_var = False ) res2 = ( mu - y . value ) ** 2 acf , ci , qstat , pvals = sm . tsa . stattools . acf ( res2 - np . mean ( res2 ) , qstat = True , alpha = 0.05 ) if plot : sm . graphics . tsa . plot_acf ( res2 - np . mean ( res2 ) ) """
      lags, c, l, b = axs[1,1].acorr(res2 - np.mean(res2), maxlags=None, lw=2, color='k')
      maxlag = (len(lags)-2)/2
      # White noise
      wnoise_upper = 1.96/np.sqrt(len(x))
      wnoise_lower = -1.96/np.sqrt(len(x))
      ax.fill_between([0, maxlag], wnoise_upper, wnoise_lower, facecolor='lightgrey')
      ax.set_ylabel(r'ACF $\chi^2$', fontsize=18)
      ax.set_xlabel(r'Time Lag (days)', fontsize=18)
      ax.set_xlim(0, maxlag)
      ax.tick_params('both', labelsize=16)
      """ return pvals [ - 1 ]
short_docstring: Compute/plot ACF of Chi^2 residuals to test model
  Note: x, y, and yerr must by astropy Quantities with units!
short_docstring_tokens: Compute / plot ACF of Chi^2 residuals to test model Note : x y and yerr must by astropy Quantities with units!
comment: """
      Compute/plot ACF of Chi^2 residuals to test model
      
      Note: x, y, and yerr must by astropy Quantities with units!
      x: time [astropy unit quantity]
      y: data [astropy unit quantity]
      gp: celerite GuassianProccess object
      samples: celerite samples array
      plot: whether or not to plot ACF(Chi^2) [bool]
      
      returns: Ljung-Box test p-value at maxlag
      """$SEP$# Plot auto-correlation function (ACF) of chi^2 residuals$SEP$"""
      lags, c, l, b = axs[1,1].acorr(res2 - np.mean(res2), maxlags=None, lw=2, color='k')
      maxlag = (len(lags)-2)/2
      # White noise
      wnoise_upper = 1.96/np.sqrt(len(x))
      wnoise_lower = -1.96/np.sqrt(len(x))
      ax.fill_between([0, maxlag], wnoise_upper, wnoise_lower, facecolor='lightgrey')
      ax.set_ylabel(r'ACF $\chi^2$', fontsize=18)
      ax.set_xlabel(r'Time Lag (days)', fontsize=18)
      ax.set_xlim(0, maxlag)
      ax.tick_params('both', labelsize=16)
      """