class_docstr: Implements the Scaled Unscented Kalman filter (UKF) as defined by
  Simon Julier in [1], using the formulation provided by Wan and Merle
  in [2]. This filter scales the sigma points to avoid strong nonlinearities.
  
  
  You will have to set the following attributes after constructing this
  object for the filter to perform properly.
  
  Attributes
  ----------
  
  x : numpy.array(dim_x)
      state estimate vector
  
  P : numpy.array(dim_x, dim_x)
      covariance estimate matrix
  
  R : numpy.array(dim_z, dim_z)
      measurement noise matrix
  
  Q : numpy.array(dim_x, dim_x)
      process noise matrix
  
  
  You may read the following attributes.
  
  Readable Attributes
  -------------------
  
  
  K : numpy.array
      Kalman gain
  
  y : numpy.array
      innovation residual
  
  x : numpy.array(dim_x)
      predicted/updated state (result of predict()/update())
  
  P : numpy.array(dim_x, dim_x)
      predicted/updated covariance matrix (result of predict()/update())
  
  likelihood : scalar
      Likelihood of last measurement update.
  
  log_likelihood : scalar
      Log likelihood of last measurement update.
  
  
  References
  ----------
  
  .. [1] Julier, Simon J. "The scaled unscented transformation,"
      American Control Converence, 2002, pp 4555-4559, vol 6.
  
      Online copy:
      https://www.cs.unc.edu/~welch/kalman/media/pdf/ACC02-IEEE1357.PDF
  
  
  .. [2] E. A. Wan and R. Van der Merwe, “The unscented Kalman filter for
      nonlinear estimation,” in Proc. Symp. Adaptive Syst. Signal
      Process., Commun. Contr., Lake Louise, AB, Canada, Oct. 2000.
  
      Online Copy:
      https://www.seas.harvard.edu/courses/cs281/papers/unscented.pdf
class_docstr_tok: ["Implements","the","Scaled","Unscented","Kalman","filter","(","UKF",")","as","defined","by","Simon","Julier","in","[","1","]",",","using","the","formulation","provided","by","Wan","and","Merle","in","[","2","]",".","This","filter","scales","the","sigma","points","to","avoid","strong","nonlinearities",".","You","will","have","to","set","the","following","attributes","after","constructing","this","object","for","the","filter","to","perform","properly",".","Attributes","--","--","--","--","--","x",":","numpy.array","(","dim_x",")","state","estimate","vector","P",":","numpy.array","(","dim_x",",","dim_x",")","covariance","estimate","matrix","R",":","numpy.array","(","dim_z",",","dim_z",")","measurement","noise","matrix","Q",":","numpy.array","(","dim_x",",","dim_x",")","process","noise","matrix","You","may","read","the","following","attributes",".","Readable","Attributes","--","--","--","--","--","--","--","--","--","-","K",":","numpy.array","Kalman","gain","y",":","numpy.array","innovation","residual","x",":","numpy.array","(","dim_x",")","predicted\/updated","state","(","result","of","predict","(",")","\/update","(",")",")","P",":","numpy.array","(","dim_x",",","dim_x",")","predicted\/updated","covariance","matrix","(","result","of","predict","(",")","\/update","(",")",")","likelihood",":","scalar","Likelihood","of","last","measurement","update",".","log_likelihood",":","scalar","Log","likelihood","of","last","measurement","update",".","References","--","--","--","--","--","..","[","1","]","Julier",",","Simon","J",".","``","The","scaled","unscented","transformation",",","''","American","Control","Converence",",","2002",",","pp","4555-4559",",","vol","6",".","Online","copy",":","https",":","\/\/www.cs.unc.edu\/~welch\/kalman\/media\/pdf\/ACC02-IEEE1357.PDF","..","[","2","]","E.","A.","Wan","and","R.","Van","der","Merwe",",","\u201c","The","unscented","Kalman","filter","for","nonlinear","estimation",",","\u201d","in","Proc",".","Symp",".","Adaptive","Syst",".","Signal","Process.",",","Commun",".","Contr.",",","Lake","Louise",",","AB",",","Canada",",","Oct.","2000",".","Online","Copy",":","https",":","\/\/www.seas.harvard.edu\/courses\/cs281\/papers\/unscented.pdf"]
docstr: Runs the Rauch-Tung-Striebel Kalman smoother on a set of
  means and covariances computed by the UKF. The usual input
  would come from the output of `batch_filter()`.
  
  Parameters
  ----------
  
  Xs : numpy.array
     array of the means (state variable x) of the output of a Kalman
     filter.
  
  Ps : numpy.array
      array of the covariances of the output of a kalman filter.
  
  Qs: list-like collection of numpy.array, optional
      Process noise of the Kalman filter at each time step. Optional,
      if not provided the filter's self.Q will be used
  
  dt : optional, float or array-like of float
      If provided, specifies the time step of each step of the filter.
      If float, then the same time step is used for all steps. If
      an array, then each element k contains the time  at step k.
      Units are seconds.
  
  Returns
  -------
  
  x : numpy.ndarray
     smoothed means
  
  P : numpy.ndarray
     smoothed state covariances
  
  K : numpy.ndarray
      smoother gain at each step
  
  Examples
  --------
  
  .. code-block:: Python
  
      zs = [t + random.randn()*4 for t in range (40)]
  
      (mu, cov, _, _) = kalman.batch_filter(zs)
      (x, P, K) = rts_smoother(mu, cov, fk.F, fk.Q)
docstr_tok: ["Runs","the","Rauch-Tung-Striebel","Kalman","smoother","on","a","set","of","means","and","covariances","computed","by","the","UKF",".","The","usual","input","would","come","from","the","output","of","`","batch_filter","(",")","`",".","Parameters","--","--","--","--","--","Xs",":","numpy.array","array","of","the","means","(","state","variable","x",")","of","the","output","of","a","Kalman","filter",".","Ps",":","numpy.array","array","of","the","covariances","of","the","output","of","a","kalman","filter",".","Qs",":","list-like","collection","of","numpy.array",",","optional","Process","noise","of","the","Kalman","filter","at","each","time","step",".","Optional",",","if","not","provided","the","filter","'s","self.Q","will","be","used","dt",":","optional",",","float","or","array-like","of","float","If","provided",",","specifies","the","time","step","of","each","step","of","the","filter",".","If","float",",","then","the","same","time","step","is","used","for","all","steps",".","If","an","array",",","then","each","element","k","contains","the","time","at","step","k.","Units","are","seconds",".","Returns","--","--","--","-","x",":","numpy.ndarray","smoothed","means","P",":","numpy.ndarray","smoothed","state","covariances","K",":","numpy.ndarray","smoother","gain","at","each","step","Examples","--","--","--","--","..","code-block",":",":","Python","zs","=","[","t","+","random.randn","(",")","*","4","for","t","in","range","(","40",")","]","(","mu",",","cov",",","_",",","_",")","=","kalman.batch_filter","(","zs",")","(","x",",","P",",","K",")","=","rts_smoother","(","mu",",","cov",",","fk.F",",","fk.Q",")"]
code: def rts_smoother(self, Xs, Ps, Qs=None, dt=None):
      """Runs the Rauch-Tung-Striebel Kalman smoother on a set of
      means and covariances computed by the UKF. The usual input
      would come from the output of `batch_filter()`.
  
      Parameters
      ----------
  
      Xs : numpy.array
         array of the means (state variable x) of the output of a Kalman
         filter.
  
      Ps : numpy.array
          array of the covariances of the output of a kalman filter.
  
      Qs: list-like collection of numpy.array, optional
          Process noise of the Kalman filter at each time step. Optional,
          if not provided the filter's self.Q will be used
  
      dt : optional, float or array-like of float
          If provided, specifies the time step of each step of the filter.
          If float, then the same time step is used for all steps. If
          an array, then each element k contains the time  at step k.
          Units are seconds.
  
      Returns
      -------
  
      x : numpy.ndarray
         smoothed means
  
      P : numpy.ndarray
         smoothed state covariances
  
      K : numpy.ndarray
          smoother gain at each step
  
      Examples
      --------
  
      .. code-block:: Python
  
          zs = [t + random.randn()*4 for t in range (40)]
  
          (mu, cov, _, _) = kalman.batch_filter(zs)
          (x, P, K) = rts_smoother(mu, cov, fk.F, fk.Q)
      """
  
      assert len(Xs) == len(Ps)
      n, dim_x, _ = Xs.shape
  
      if dt is None:
          dt = [self._dt] * n
      elif isscalar(dt):
          dt = [dt] * n
  
      if Qs is None:
          Qs = [self.Q] * n
  
      # smoother gain
      Ks = zeros((n, dim_x, dim_x))
  
      num_sigmas = self._num_sigmas
  
      xs, ps = Xs.copy(), Ps.copy()
      sigmas_f = zeros((dim_x, num_sigmas))
  
      for k in range(n - 2, -1, -1):
          # create sigma points from state estimate, pass through state func
          sigmas = self.points_fn.sigma_points(xs[k], ps[k])
          for i in range(num_sigmas):
              sigmas_f[:, i] = self.fx(sigmas[:, i], dt[k])
  
          # compute backwards prior state and covariance
          xb = dot(sigmas_f, self.Wm)
          Pb = 0
          x = Xs[k]
          for i in range(num_sigmas):
              y = self.residual_x(sigmas_f[:, i : i + 1], x)
              Pb += self.Wc[i] * outer(y, y)
          Pb += Qs[k]
  
          # compute cross variance
          Pxb = 0
          for i in range(num_sigmas):
              z = self.residual_x(sigmas[:, i : i + 1], Xs[k])
              y = self.residual_x(sigmas_f[:, i : i + 1], xb)
              Pxb += self.Wc[i] * outer(z, y)
  
          # compute gain
          K = dot(Pxb, inv(Pb))
  
          # update the smoothed estimates
          xs[k] += dot(K, self.residual_x(xs[k + 1], xb))
          ps[k] += dot3(K, ps[k + 1] - Pb, K.T)
          Ks[k] = K
  
      return (xs, ps, Ks)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import matplotlib.pyplot
  import numpy.random
  from numpy.random import randn
  from numpy import asarray
  import numpy
  from filterpy.kalman import UnscentedKalmanFilter
  from filterpy.kalman import unscented_transform, MerweScaledSigmaPoints, JulierSigmaPoints, SimplexSigmaPoints
  from filterpy.common import Q_discrete_white_noise
  import filterpy.stats
  from math import cos, sin
  from filterpy.kalman import UnscentedKalmanFilter2
label_desc: Use image node_id 6 for calling the UnscentedKalmanFilter2 obj's underlying member method code with example usage: obj.rts_smoother(Xs, Ps, Qs, dt) and returns: xs,  ps,  Ks