class_docstr: differential equation:
  
  :math::
  dx_t = f(t,x)dt + \sigma(t,x)dW_t
  
  integral:
  
  :math::
  x_T = x_0 + \int_{0}^{T}f(t,S)dt + \int_0^T  \sigma(t,S)dW_t
  
  TODO: check definition, affine, what about jump diffusion?
class_docstr_tok: ["differential","equation",":",":","math",":",":","dx_t","=","f","(","t",",","x",")","dt","+","\\sigma","(","t",",","x",")","dW_t","integral",":",":","math",":",":","x_T","=","x_0","+","\\int_","{","0","}","^","{","T","}","f","(","t",",","S",")","dt","+","\\int_0^T","\\sigma","(","t",",","S",")","dW_t","TODO",":","check","definition",",","affine",",","what","about","jump","diffusion","?"]
docstr: from Higham 2001
  
  TODO: reverse parameterization to start with final nobs and DT
  TODO: check if I can skip the loop using my way from exactprocess
        problem might be Winc (reshape into 3d and sum)
  TODO: (later) check memory efficiency for large simulations
docstr_tok: ["from","Higham","2001","TODO",":","reverse","parameterization","to","start","with","final","nobs","and","DT","TODO",":","check","if","I","can","skip","the","loop","using","my","way","from","exactprocess","problem","might","be","Winc","(","reshape","into","3d","and","sum",")","TODO",":","(","later",")","check","memory","efficiency","for","large","simulations"]
code: def simEM(
      self, xzero=None, nobs=100, T=1, dt=None, nrepl=1, Tratio=4
  ):
      """
  
      from Higham 2001
  
      TODO: reverse parameterization to start with final nobs and DT
      TODO: check if I can skip the loop using my way from exactprocess
            problem might be Winc (reshape into 3d and sum)
      TODO: (later) check memory efficiency for large simulations
      """
      # TODO: reverse parameterization to start with final nobs and DT
      nobs = nobs * Tratio  # simple way to change parameter
      # maybe wrong parameterization,
      # drift too large, variance too small ? which dt/Dt
      # _drift, _sig independent of dt is wrong
      if xzero is None:
          xzero = self.xzero
      if dt is None:
          dt = T * 1.0 / nobs
      W, t = self.simulateW(nobs=nobs, T=T, dt=dt, nrepl=nrepl)
      dW = self.dW
      t = np.linspace(dt, 1, nobs)
      Dt = Tratio * dt
      L = nobs / Tratio  # L EM steps of size Dt = R*dt
      Xem = np.zeros((nrepl, L))  # preallocate for efficiency
      Xtemp = xzero
      Xem[:, 0] = xzero
      for j in np.arange(1, L):
          # Winc = np.sum(dW[:,Tratio*(j-1)+1:Tratio*j],1)
          Winc = np.sum(
              dW[:, np.arange(Tratio * (j - 1) + 1, Tratio * j)], 1
          )
          # Xtemp = Xtemp + Dt*lamda*Xtemp + mu*Xtemp*Winc;
          Xtemp = (
              Xtemp + self._drift(x=Xtemp) + self._sig(x=Xtemp) * Winc
          )
          # Dt*lamda*Xtemp + mu*Xtemp*Winc;
          Xem[:, j] = Xtemp
      return Xem
  
imports: import numpy
  from scipy import stats, signal
  import matplotlib.pyplot
label_desc: Use image node_id 3 for calling the AffineDiffusion obj's underlying member method code with example usage: obj.simEM(xzero, nobs, T, dt, nrepl, Tratio) and returns: Xem