class_docstr: Implements a Least Squares recursive filter. Formulation is per
  Zarchan [1]_.
  
  Filter may be of order 0 to 2. Order 0 assumes the value being tracked is
  a constant, order 1 assumes that it moves in a line, and order 2 assumes
  that it is tracking a second order polynomial.
  
  
  Parameters
  ----------
  
  dt : float
     time step per update
  
  order : int
      order of filter 0..2
  
  noise_sigma : float
      sigma (std dev) in x. This allows us to calculate the error of
      the filter, it does not influence the filter output.
  
  
  Attributes
  ----------
  
  n : int
      step in the recursion. 0 prior to first call, 1 after the first call,
      etc.
  
  K : np.array
      Gains for the filter. K[0] for all orders, K[1] for orders 0 and 1, and
      K[2] for order 2
  
  x: np.array (order + 1, 1)
      estimate(s) of the output. It is a vector containing the estimate x
      and the derivatives of x: [x x' x''].T. It contains as many
      derivatives as the order allows. That is, a zero order filter has
      no derivatives, a first order has one derivative, and a second order
      has two.
  
  y : float
      residual (difference between measurement projection of previous
      estimate to current time).
  
  Examples
  --------
  
  .. code-block:: Python
  
      from filterpy.leastsq import LeastSquaresFilter
  
      lsq = LeastSquaresFilter(dt=0.1, order=1, noise_sigma=2.3)
  
      while True:
          z = sensor_reading()  # get a measurement
          x = lsq.update(z)     # get the filtered estimate.
          print('error: {}, velocity error: {}'.format(
                lsq.error, lsq.derror))
  
  References
  ----------
  
  .. [1] Zarchan and Musoff. "Fundamentals of Kalman Filtering: A Practical
        Approach." Third Edition. AIAA, 2009.
class_docstr_tok: ["Implements","a","Least","Squares","recursive","filter",".","Formulation","is","per","Zarchan","[","1","]","_.","Filter","may","be","of","order","0","to","2",".","Order","0","assumes","the","value","being","tracked","is","a","constant",",","order","1","assumes","that","it","moves","in","a","line",",","and","order","2","assumes","that","it","is","tracking","a","second","order","polynomial",".","Parameters","--","--","--","--","--","dt",":","float","time","step","per","update","order",":","int","order","of","filter","0","..","2","noise_sigma",":","float","sigma","(","std","dev",")","in","x",".","This","allows","us","to","calculate","the","error","of","the","filter",",","it","does","not","influence","the","filter","output",".","Attributes","--","--","--","--","--","n",":","int","step","in","the","recursion",".","0","prior","to","first","call",",","1","after","the","first","call",",","etc",".","K",":","np.array","Gains","for","the","filter",".","K","[","0","]","for","all","orders",",","K","[","1","]","for","orders","0","and","1",",","and","K","[","2","]","for","order","2","x",":","np.array","(","order","+","1",",","1",")","estimate","(","s",")","of","the","output",".","It","is","a","vector","containing","the","estimate","x","and","the","derivatives","of","x",":","[","x","x","'","x","''","]",".T",".","It","contains","as","many","derivatives","as","the","order","allows",".","That","is",",","a","zero","order","filter","has","no","derivatives",",","a","first","order","has","one","derivative",",","and","a","second","order","has","two",".","y",":","float","residual","(","difference","between","measurement","projection","of","previous","estimate","to","current","time",")",".","Examples","--","--","--","--","..","code-block",":",":","Python","from","filterpy.leastsq","import","LeastSquaresFilter","lsq","=","LeastSquaresFilter","(","dt=0.1",",","order=1",",","noise_sigma=2.3",")","while","True",":","z","=","sensor_reading","(",")","#","get","a","measurement","x","=","lsq.update","(","z",")","#","get","the","filtered","estimate",".","print","(","'error",":","{","}",",","velocity","error",":","{","}","'.format","(","lsq.error",",","lsq.derror",")",")","References","--","--","--","--","--","..","[","1","]","Zarchan","and","Musoff",".","``","Fundamentals","of","Kalman","Filtering",":","A","Practical","Approach",".","''","Third","Edition",".","AIAA",",","2009","."]
docstr: reset filter back to state at time of construction
docstr_tok: ["reset","filter","back","to","state","at","time","of","construction"]
code: def reset(self):
      """reset filter back to state at time of construction"""
  
      self.n = 0  # nth step in the recursion
      self.x = np.zeros(self._order + 1)
      self.K = np.zeros(self._order + 1)
      self.y = 0
  
file_path: filterpy/filterpy/leastsq/least_squares.py
imports: from __future__ import absolute_import, division
  from math import sqrt
  import numpy
  from filterpy.kalman import pretty_str
label_desc: Use image node_id 2 for calling the LeastSquaresFilter obj's underlying member method code with example usage: obj.reset() without return types