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 the g-h filter predict and update step on the
  measurement z.
  
  On return, self.x, self.dx, self.y, and self.x_prediction
  will have been updated with the results of the computation. For
  convienence, self.x and self.dx are returned in a tuple.
  
  Parameters
  ----------
  
  z : scalar
      the measurement
  g : scalar (optional)
      Override the fixed self.g value for this update
  h : scalar (optional)
      Override the fixed self.h value for this update
  k : scalar (optional)
      Override the fixed self.k value for this update
  
  Returns
  -------
  
  x filter output for x
  dx filter output for dx (derivative of x
docstr_tok: ["Performs","the","g-h","filter","predict","and","update","step","on","the","measurement","z",".","On","return",",","self.x",",","self.dx",",","self.y",",","and","self.x_prediction","will","have","been","updated","with","the","results","of","the","computation",".","For","convienence",",","self.x","and","self.dx","are","returned","in","a","tuple",".","Parameters","--","--","--","--","--","z",":","scalar","the","measurement","g",":","scalar","(","optional",")","Override","the","fixed","self.g","value","for","this","update","h",":","scalar","(","optional",")","Override","the","fixed","self.h","value","for","this","update","k",":","scalar","(","optional",")","Override","the","fixed","self.k","value","for","this","update","Returns","--","--","--","-","x","filter","output","for","x","dx","filter","output","for","dx","(","derivative","of","x"]
code: def update(self, z, g=None, h=None, k=None):
      """
      Performs the g-h filter predict and update step on the
      measurement z.
  
      On return, self.x, self.dx, self.y, and self.x_prediction
      will have been updated with the results of the computation. For
      convienence, self.x and self.dx are returned in a tuple.
  
      Parameters
      ----------
  
      z : scalar
          the measurement
      g : scalar (optional)
          Override the fixed self.g value for this update
      h : scalar (optional)
          Override the fixed self.h value for this update
      k : scalar (optional)
          Override the fixed self.k value for this update
  
      Returns
      -------
  
      x filter output for x
      dx filter output for dx (derivative of x
  
      """
  
      if g is None:
          g = self.g
      if h is None:
          h = self.h
      if k is None:
          k = self.k
  
      dt = self.dt
      dt_sqr = dt**2
      # prediction step
      self.ddx_prediction = self.ddx
      self.dx_prediction = self.dx + self.ddx * dt
      self.x_prediction = (
          self.x + self.dx * dt + 0.5 * self.ddx * (dt_sqr)
      )
  
      # update step
      self.y = z - self.x_prediction
  
      self.ddx = self.ddx_prediction + 2 * k * self.y / dt_sqr
      self.dx = self.dx_prediction + h * self.y / dt
      self.x = self.x_prediction + g * self.y
  
      return (self.x, self.dx)
  
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 2 for calling the GHKFilter obj's underlying member method code with example usage: obj.update(z, g, h, k) and returns: self,  self