class_docstr: Fixed Lag Kalman smoother.
  
  Computes a smoothed sequence from a set of measurements based on the
  fixed lag Kalman smoother. At time k, for a lag N, the fixed-lag smoother
  computes the state estimate for time k-N based on all measurements made
  between times k-N and k. This yields a pretty good smoothed result with
  O(N) extra computations performed for each measurement. In other words,
  if N=4 this will consume about 5x the number of computations as a
  basic Kalman filter. However, the loops contain only 3 dot products, so it
  will be much faster than this sounds as the main Kalman filter loop
  involves transposes and inverses, as well as many more matrix
  multiplications.
  
  Implementation based on Wikipedia article as it existed on
  November 18, 2014.
  
  
  Examples
  --------
  
  .. code-block:: Python
  
      from filterpy.kalman import FixedLagSmoother
      fls = FixedLagSmoother(dim_x=2, dim_z=1)
  
      fls.x = np.array([[0.],
                        [.5]])
  
      fls.F = np.array([[1.,1.],
                        [0.,1.]])
  
      fls.H = np.array([[1.,0.]])
  
      fls.P *= 200
      fls.R *= 5.
      fls.Q *= 0.001
  
      zs = [...some measurements...]
      xhatsmooth, xhat = fls.smooth_batch(zs, N=4)
  
  
  See my book Kalman and Bayesian Filters in Python
  https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
  
  
  References
  ----------
  
  Wikipedia http://en.wikipedia.org/wiki/Kalman_filter#Fixed-lag_smoother
  
  Simon, Dan. "Optimal State Estimation," John Wiley & Sons pp 274-8 (2006).
  
  |
  |
class_docstr_tok: ["Fixed","Lag","Kalman","smoother",".","Computes","a","smoothed","sequence","from","a","set","of","measurements","based","on","the","fixed","lag","Kalman","smoother",".","At","time","k",",","for","a","lag","N",",","the","fixed-lag","smoother","computes","the","state","estimate","for","time","k-N","based","on","all","measurements","made","between","times","k-N","and","k.","This","yields","a","pretty","good","smoothed","result","with","O","(","N",")","extra","computations","performed","for","each","measurement",".","In","other","words",",","if","N=4","this","will","consume","about","5x","the","number","of","computations","as","a","basic","Kalman","filter",".","However",",","the","loops","contain","only","3","dot","products",",","so","it","will","be","much","faster","than","this","sounds","as","the","main","Kalman","filter","loop","involves","transposes","and","inverses",",","as","well","as","many","more","matrix","multiplications",".","Implementation","based","on","Wikipedia","article","as","it","existed","on","November","18",",","2014",".","Examples","--","--","--","--","..","code-block",":",":","Python","from","filterpy.kalman","import","FixedLagSmoother","fls","=","FixedLagSmoother","(","dim_x=2",",","dim_z=1",")","fls.x","=","np.array","(","[","[","0",".","]",",","[",".5","]","]",")","fls.F","=","np.array","(","[","[","1.,1",".","]",",","[","0.,1",".","]","]",")","fls.H","=","np.array","(","[","[","1.,0",".","]","]",")","fls.P","*","=","200","fls.R","*","=","5.","fls.Q","*","=","0.001","zs","=","[","...","some","measurements","...","]","xhatsmooth",",","xhat","=","fls.smooth_batch","(","zs",",","N=4",")","See","my","book","Kalman","and","Bayesian","Filters","in","Python","https",":","\/\/github.com\/rlabbe\/Kalman-and-Bayesian-Filters-in-Python","References","--","--","--","--","--","Wikipedia","http",":","\/\/en.wikipedia.org\/wiki\/Kalman_filter","#","Fixed-lag_smoother","Simon",",","Dan",".","``","Optimal","State","Estimation",",","''","John","Wiley","&","Sons","pp","274-8","(","2006",")",".","|","|"]
docstr: Create a fixed lag Kalman filter smoother. You are responsible for
  setting the various state variables to reasonable values; the defaults
  below will not give you a functional filter.
  
  Parameters
  ----------
  
  dim_x : int
      Number of state variables for the Kalman filter. For example, if
      you are tracking the position and velocity of an object in two
      dimensions, dim_x would be 4.
  
      This is used to set the default size of P, Q, and u
  
  dim_z : int
      Number of of measurement inputs. For example, if the sensor
      provides you with position in (x,y), dim_z would be 2.
  
  N : int, optional
      If provided, the size of the lag. Not needed if you are only
      using smooth_batch() function. Required if calling smooth()
docstr_tok: ["Create","a","fixed","lag","Kalman","filter","smoother",".","You","are","responsible","for","setting","the","various","state","variables","to","reasonable","values",";","the","defaults","below","will","not","give","you","a","functional","filter",".","Parameters","--","--","--","--","--","dim_x",":","int","Number","of","state","variables","for","the","Kalman","filter",".","For","example",",","if","you","are","tracking","the","position","and","velocity","of","an","object","in","two","dimensions",",","dim_x","would","be","4",".","This","is","used","to","set","the","default","size","of","P",",","Q",",","and","u","dim_z",":","int","Number","of","of","measurement","inputs",".","For","example",",","if","the","sensor","provides","you","with","position","in","(","x",",","y",")",",","dim_z","would","be","2",".","N",":","int",",","optional","If","provided",",","the","size","of","the","lag",".","Not","needed","if","you","are","only","using","smooth_batch","(",")","function",".","Required","if","calling","smooth","(",")"]
code: def __init__(self, dim_x, dim_z, N=None):
      """Create a fixed lag Kalman filter smoother. You are responsible for
      setting the various state variables to reasonable values; the defaults
      below will not give you a functional filter.
  
      Parameters
      ----------
  
      dim_x : int
          Number of state variables for the Kalman filter. For example, if
          you are tracking the position and velocity of an object in two
          dimensions, dim_x would be 4.
  
          This is used to set the default size of P, Q, and u
  
      dim_z : int
          Number of of measurement inputs. For example, if the sensor
          provides you with position in (x,y), dim_z would be 2.
  
      N : int, optional
          If provided, the size of the lag. Not needed if you are only
          using smooth_batch() function. Required if calling smooth()
      """
  
      self.dim_x = dim_x
      self.dim_z = dim_z
      self.N = N
  
      self.x = zeros((dim_x, 1))  # state
      self.x_s = zeros((dim_x, 1))  # smoothed state
      self.P = eye(dim_x)  # uncertainty covariance
      self.Q = eye(dim_x)  # process uncertainty
      self.F = eye(dim_x)  # state transition matrix
      self.H = eye(dim_z, dim_x)  # Measurement function
      self.R = eye(dim_z)  # state uncertainty
      self.K = zeros((dim_x, 1))  # kalman gain
      self.y = zeros((dim_z, 1))
      self.B = 0.0
      self.S = zeros((dim_z, dim_z))
  
      # identity matrix. Do not alter this.
      self._I = np.eye(dim_x)
  
      self.count = 0
  
      if N is not None:
          self.xSmooth = []
  
file_path: filterpy/filterpy/kalman/fixed_lag_smoother.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy
  from numpy import dot, zeros, eye
  from scipy.linalg import inv
  from filterpy.common import pretty_str
label_desc: Use image node_id 1 to create a new FixedLagSmoother object from inherited base classes: object with example: obj = FixedLagSmoother(dim_x, dim_z, N)