class_docstr: Implements the g-h-k filter.
  
  Parameters
  ----------
  
  x : 1D np.array or scalar
      Initial value for the filter state. Each value can be a scalar
      or a np.array.
  
      You can use a scalar for x0. If order > 0, then 0.0 is assumed
      for the higher order terms.
  
      x[0] is the value being tracked
      x[1] is the first derivative (for order 1 and 2 filters)
      x[2] is the second derivative (for order 2 filters)
  
  dx : 1D np.array or scalar
      Initial value for the derivative of the filter state.
  
  ddx : 1D np.array or scalar
      Initial value for the second derivative of the filter state.
  
  dt : scalar
      time step
  
  g : float
      filter g gain parameter.
  
  h : float
      filter h gain parameter.
  
  k : float
      filter k gain parameter.
  
  
  
  Attributes
  ----------
  x : 1D np.array or scalar
      filter state
  
  dx : 1D np.array or scalar
     derivative of the filter state.
  
  ddx : 1D np.array or scalar
     second derivative of the filter state.
  
  x_prediction : 1D np.array or scalar
      predicted filter state
  
  dx_prediction : 1D np.array or scalar
     predicted derivative of the filter state.
  
  ddx_prediction : 1D np.array or scalar
     second predicted derivative of the filter state.
  
  dt : scalar
      time step
  
  g : float
      filter g gain parameter.
  
  h : float
      filter h gain parameter.
  
  k : float
      filter k gain parameter.
  
  y : np.array, or scalar
      residual (difference between measurement and prior)
  
  z : np.array, or scalar
      measurement passed into update()
  
  References
  ----------
  
  Brookner, "Tracking and Kalman Filters Made Easy". John Wiley and
  Sons, 1998.
class_docstr_tok: ["Implements","the","g-h-k","filter",".","Parameters","--","--","--","--","--","x",":","1D","np.array","or","scalar","Initial","value","for","the","filter","state",".","Each","value","can","be","a","scalar","or","a","np.array",".","You","can","use","a","scalar","for","x0",".","If","order",">","0",",","then","0.0","is","assumed","for","the","higher","order","terms",".","x","[","0","]","is","the","value","being","tracked","x","[","1","]","is","the","first","derivative","(","for","order","1","and","2","filters",")","x","[","2","]","is","the","second","derivative","(","for","order","2","filters",")","dx",":","1D","np.array","or","scalar","Initial","value","for","the","derivative","of","the","filter","state",".","ddx",":","1D","np.array","or","scalar","Initial","value","for","the","second","derivative","of","the","filter","state",".","dt",":","scalar","time","step","g",":","float","filter","g","gain","parameter",".","h",":","float","filter","h","gain","parameter",".","k",":","float","filter","k","gain","parameter",".","Attributes","--","--","--","--","--","x",":","1D","np.array","or","scalar","filter","state","dx",":","1D","np.array","or","scalar","derivative","of","the","filter","state",".","ddx",":","1D","np.array","or","scalar","second","derivative","of","the","filter","state",".","x_prediction",":","1D","np.array","or","scalar","predicted","filter","state","dx_prediction",":","1D","np.array","or","scalar","predicted","derivative","of","the","filter","state",".","ddx_prediction",":","1D","np.array","or","scalar","second","predicted","derivative","of","the","filter","state",".","dt",":","scalar","time","step","g",":","float","filter","g","gain","parameter",".","h",":","float","filter","h","gain","parameter",".","k",":","float","filter","k","gain","parameter",".","y",":","np.array",",","or","scalar","residual","(","difference","between","measurement","and","prior",")","z",":","np.array",",","or","scalar","measurement","passed","into","update","(",")","References","--","--","--","--","--","Brookner",",","``","Tracking","and","Kalman","Filters","Made","Easy","''",".","John","Wiley","and","Sons",",","1998","."]
docstr: Performs g-h filter with a fixed g and h.
  
  Uses self.x and self.dx to initialize the filter, but DOES NOT
  alter self.x and self.dx during execution, allowing you to use this
  class multiple times without reseting self.x and self.dx. I'm not sure
  how often you would need to do that, but the capability is there.
  More exactly, none of the class member variables are modified
  by this function.
  
  Parameters
  ----------
  
  data : list_like
      contains the data to be filtered.
  
  save_predictions : boolean
      The predictions will be saved and returned if this is true
  
  Returns
  -------
  
  results : np.array shape (n+1, 2), where n=len(data)
     contains the results of the filter, where
     results[i,0] is x , and
     results[i,1] is dx (derivative of x)
     First entry is the initial values of x and dx as set by __init__.
  
  predictions : np.array shape(n), or None
     the predictions for each step in the filter. Only returned if
     save_predictions == True
docstr_tok: ["Performs","g-h","filter","with","a","fixed","g","and","h.","Uses","self.x","and","self.dx","to","initialize","the","filter",",","but","DOES","NOT","alter","self.x","and","self.dx","during","execution",",","allowing","you","to","use","this","class","multiple","times","without","reseting","self.x","and","self.dx",".","I","'m","not","sure","how","often","you","would","need","to","do","that",",","but","the","capability","is","there",".","More","exactly",",","none","of","the","class","member","variables","are","modified","by","this","function",".","Parameters","--","--","--","--","--","data",":","list_like","contains","the","data","to","be","filtered",".","save_predictions",":","boolean","The","predictions","will","be","saved","and","returned","if","this","is","true","Returns","--","--","--","-","results",":","np.array","shape","(","n+1",",","2",")",",","where","n=len","(","data",")","contains","the","results","of","the","filter",",","where","results","[","i,0","]","is","x",",","and","results","[","i,1","]","is","dx","(","derivative","of","x",")","First","entry","is","the","initial","values","of","x","and","dx","as","set","by","__init__",".","predictions",":","np.array","shape","(","n",")",",","or","None","the","predictions","for","each","step","in","the","filter",".","Only","returned","if","save_predictions","==","True"]
code: def batch_filter(self, data, save_predictions=False):
      """
      Performs g-h filter with a fixed g and h.
  
      Uses self.x and self.dx to initialize the filter, but DOES NOT
      alter self.x and self.dx during execution, allowing you to use this
      class multiple times without reseting self.x and self.dx. I'm not sure
      how often you would need to do that, but the capability is there.
      More exactly, none of the class member variables are modified
      by this function.
  
      Parameters
      ----------
  
      data : list_like
          contains the data to be filtered.
  
      save_predictions : boolean
          The predictions will be saved and returned if this is true
  
      Returns
      -------
  
      results : np.array shape (n+1, 2), where n=len(data)
         contains the results of the filter, where
         results[i,0] is x , and
         results[i,1] is dx (derivative of x)
         First entry is the initial values of x and dx as set by __init__.
  
      predictions : np.array shape(n), or None
         the predictions for each step in the filter. Only returned if
         save_predictions == True
      """
  
      x = self.x
      dx = self.dx
      n = len(data)
  
      results = np.zeros((n + 1, 2))
      results[0, 0] = x
      results[0, 1] = dx
  
      if save_predictions:
          predictions = np.zeros(n)
  
      # optimization to avoid n computations of h / dt
      h_dt = self.h / self.dt
  
      for i, z in enumerate(data):
          # prediction step
          x_est = x + (dx * self.dt)
  
          # update step
          residual = z - x_est
          dx = dx + h_dt * residual  # i.e. dx = dx + h * residual / dt
          x = x_est + self.g * residual
  
          results[i + 1, 0] = x
          results[i + 1, 1] = dx
          if save_predictions:
              predictions[i] = x_est
  
      if save_predictions:
          return results, predictions
  
      return results
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy
  from numpy import dot
  from filterpy.common import pretty_str
label_desc: Use image node_id 3 for calling the GHKFilter obj's underlying member method code with example usage: obj.batch_filter(data, save_predictions) and returns: results, results,  predictions