code: def generate_damped_RW(
      t_rest, tau=300.0, z=2.0, xmean=0, SFinf=0.3, random_state=None
  ):
      """Generate a damped random walk light curve
  
      This uses a damped random walk model to generate a light curve similar
      to that of a QSO [1]_.
  
      Parameters
      ----------
      t_rest : array_like
          rest-frame time.  Should be in increasing order
      tau : float
          relaxation time
      z : float
          redshift
      xmean : float (optional)
          mean value of random walk; default=0
      SFinf : float (optional
          Structure function at infinity; default=0.3
      random_state : None, int, or np.random.RandomState instance (optional)
          random seed or random number generator
  
      Returns
      -------
      x : ndarray
          the sampled values corresponding to times t_rest
  
      Notes
      -----
      The differential equation is (with t = time/tau):
  
          dX = -X(t) * dt + sigma * sqrt(tau) * e(t) * sqrt(dt) + b * tau * dt
  
      where e(t) is white noise with zero mean and unit variance, and
  
          Xmean = b * tau
          SFinf = sigma * sqrt(tau / 2)
  
      so
  
          dX(t) = -X(t) * dt + sqrt(2) * SFint * e(t) * sqrt(dt) + Xmean * dt
  
      References
      ----------
      .. [1] Kelly, B., Bechtold, J. & Siemiginowska, A. (2009)
             Are the Variations in Quasar Optical Flux Driven by Thermal
             Fluctuations? ApJ 698:895 (2009)
      """
      #  Xmean = b * tau
      #  SFinf = sigma * sqrt(tau / 2)
      t_rest = np.atleast_1d(t_rest)
  
      if t_rest.ndim != 1:
          raise ValueError("t_rest should be a 1D array")
  
      random_state = check_random_state(random_state)
  
      N = len(t_rest)
  
      t_obs = t_rest * (1.0 + z) / tau
  
      x = np.zeros(N)
      x[0] = random_state.normal(xmean, SFinf)
      E = random_state.normal(0, 1, N)
  
      for i in range(1, N):
          dt = t_obs[i] - t_obs[i - 1]
          x[i] = (
              x[i - 1]
              - dt * (x[i - 1] - xmean)
              + np.sqrt(2) * SFinf * E[i] * np.sqrt(dt)
          )
  
      return x
  
imports: import numpy
  from sklearn.utils import check_random_state
label_desc: Use image node_id 2 for calling a global function with example usage: generate_damped_RW(t_rest, tau, z, xmean, SFinf, random_state) and returns: x