class_docstr: State-Centric EKF (Extended Kalman Filter) for use with either an NCP
  (Nearly-Constant Position) or NCV (Nearly-Constant Velocity) target dynamic
  model. Stores a target dynamic model, state estimate, and state time.
  Incoming ``Measurement`` provide sensor information for updates.
  
  .. warning:: For efficiency, the dynamic model is only shallow-copied. Make
      a deep copy outside as necessary to protect against unexpected changes.
  
  :param dynamic_model: target dynamic model.
  :param mean: mean of target state estimate.
  :param cov: covariance of target state estimate.
  :param time: time of state estimate.
class_docstr_tok: ["State-Centric","EKF","(","Extended","Kalman","Filter",")","for","use","with","either","an","NCP","(","Nearly-Constant","Position",")","or","NCV","(","Nearly-Constant","Velocity",")","target","dynamic","model",".","Stores","a","target","dynamic","model",",","state","estimate",",","and","state","time",".","Incoming","``","Measurement","``","provide","sensor","information","for","updates",".","..","warning",":",":","For","efficiency",",","the","dynamic","model","is","only","shallow-copied",".","Make","a","deep","copy","outside","as","necessary","to","protect","against","unexpected","changes",".",":","param","dynamic_model",":","target","dynamic","model",".",":","param","mean",":","mean","of","target","state","estimate",".",":","param","cov",":","covariance","of","target","state","estimate",".",":","param","time",":","time","of","state","estimate","."]
docstr: Use measurement to update state estimate in-place and return
  innovation. The innovation is useful, e.g., for evaluating filter
  consistency or updating model likelihoods when the ``EKFState`` is part
  of an ``IMMFState``.
  
  :param: measurement.
  :returns: EKF State, Innovation mean and covariance.
docstr_tok: ["Use","measurement","to","update","state","estimate","in-place","and","return","innovation",".","The","innovation","is","useful",",","e.g.",",","for","evaluating","filter","consistency","or","updating","model","likelihoods","when","the","``","EKFState","``","is","part","of","an","``","IMMFState","``",".",":","param",":","measurement",".",":","returns",":","EKF","State",",","Innovation","mean","and","covariance","."]
code: def update(self, measurement):
      """
      Use measurement to update state estimate in-place and return
      innovation. The innovation is useful, e.g., for evaluating filter
      consistency or updating model likelihoods when the ``EKFState`` is part
      of an ``IMMFState``.
  
      :param: measurement.
      :returns: EKF State, Innovation mean and covariance.
      """
      if self._time is not None:
          assert (
              self._time == measurement.time
          ), "State time and measurement time must be aligned!"
      if self._frame_num is not None:
          assert (
              self._frame_num == measurement.frame_num
          ), "State time and measurement time must be aligned!"
  
      x = self._mean
      x_pv = self._dynamic_model.mean2pv(x)
      P = self.cov
      H = measurement.jacobian(x_pv)[:, : self.dimension]
      R = measurement.cov
      z = measurement.mean
      z_predicted = measurement(x_pv)
      dz = measurement.geodesic_difference(z, z_predicted)
      S = H.mm(P).mm(H.transpose(-1, -2)) + R  # innovation cov
  
      K_prefix = self._cov.mm(H.transpose(-1, -2))
      dx = K_prefix.mm(torch.linalg.solve(S, dz.unsqueeze(1))).squeeze(
          1
      )  # K*dz
      x = self._dynamic_model.geodesic_difference(x, -dx)
  
      I = eye_like(x, self._dynamic_model.dimension)  # noqa: E741
      ImKH = I - K_prefix.mm(torch.linalg.solve(S, H))
      # *Joseph form* of covariance update for numerical stability.
      S_inv_R = torch.linalg.solve(S, R)
      P = ImKH.mm(self.cov).mm(ImKH.transpose(-1, -2)) + K_prefix.mm(
          torch.linalg.solve(S, K_prefix.mm(S_inv_R).transpose(-1, -2))
      )
  
      pred_mean = x
      pred_cov = P
      state = EKFState(
          self._dynamic_model,
          pred_mean,
          pred_cov,
          self._time,
          self._frame_num,
      )
  
      return state, (dz, S)
  
file_path: pyro/pyro/contrib/tracking/extended_kalman_filter.py
imports: import torch
  from torch.distributions.utils import lazy_property
  import pyro.distributions
  from pyro.distributions.util import eye_like
label_desc: Use image node_id 14 for calling the EKFState obj's underlying member method code with example usage: obj.update(measurement) and returns: state,  dz,  S