class_docstr: The kalmanFilter class the provide the basic functionalities
  
  Attributes:
      discount: the discounting factor determining how much information to carry on
      updateInnovation: indicate whether the innovation matrix should be updated.
                        default to True.
  
  Methods:
      predict: predict one step ahead of the current state
      forwardFilter: one step filter on the model given a new observation
      backwardSmoother: one step backward smooth given the future model and the
                        filtered state and systematic covariance
      backwardSampler: similar to backwardSmoother, using sampling instead of
                       deterministic equations.
      updateDiscount: for updating the discount factors
class_docstr_tok: ["The","kalmanFilter","class","the","provide","the","basic","functionalities","Attributes",":","discount",":","the","discounting","factor","determining","how","much","information","to","carry","on","updateInnovation",":","indicate","whether","the","innovation","matrix","should","be","updated",".","default","to","True",".","Methods",":","predict",":","predict","one","step","ahead","of","the","current","state","forwardFilter",":","one","step","filter","on","the","model","given","a","new","observation","backwardSmoother",":","one","step","backward","smooth","given","the","future","model","and","the","filtered","state","and","systematic","covariance","backwardSampler",":","similar","to","backwardSmoother",",","using","sampling","instead","of","deterministic","equations",".","updateDiscount",":","for","updating","the","discount","factors"]
docstr: The forwardFilter used to run one step filtering given new data
  
  Args:
      model: the @baseModel provided the basic information
      y: the newly observed data
  
  Returns:
      The filtered result is stored in the 'model' replacing the old states
docstr_tok: ["The","forwardFilter","used","to","run","one","step","filtering","given","new","data","Args",":","model",":","the","@","baseModel","provided","the","basic","information","y",":","the","newly","observed","data","Returns",":","The","filtered","result","is","stored","in","the","'model","'","replacing","the","old","states"]
code: def forwardFilter(self, model, y, dealWithMissingEvaluation=False):
      """The forwardFilter used to run one step filtering given new data
  
      Args:
          model: the @baseModel provided the basic information
          y: the newly observed data
  
      Returns:
          The filtered result is stored in the 'model' replacing the old states
  
      """
      # check whether evaluation has missing data, if so, we need to take care of it
      if dealWithMissingEvaluation:
          loc = self._modifyTransitionAccordingToMissingValue(model)
  
      # since we have delt with the missing value, we don't need to double treat it.
      self.predict(model, dealWithMissingEvaluation=False)
  
      # when y is not a missing data
      if y is not None:
          # first obtain the predicted status
          # we make the prediction step equal to 0 to ensure the prediction
          # is based on the model state and innovation is updated correctlly
          # model.prediction.step = 0
          model.prediction.step = 0
  
          # the prediction error and the correction matrix
          err = y - model.prediction.obs
          correction = (
              np.dot(model.prediction.sysVar, model.evaluation.T)
              / model.prediction.obsVar
          )
  
          # update new states
          model.df += 1
          lastNoiseVar = model.noiseVar  # for updating model.sysVar
          model.noiseVar = model.noiseVar * (
              1.0
              - 1.0 / model.df
              + err * err / model.df / model.prediction.obsVar
          )
  
          model.state = model.prediction.state + correction * err
  
          model.sysVar = (
              model.noiseVar[0, 0]
              / lastNoiseVar[0, 0]
              * (
                  model.prediction.sysVar
                  - np.dot(correction, correction.T)
                  * model.prediction.obsVar[0, 0]
              )
          )
  
          model.obs = np.dot(model.evaluation, model.state)
          model.obsVar = (
              np.dot(
                  np.dot(model.evaluation, model.sysVar),
                  model.evaluation.T,
              )
              + model.noiseVar
          )
          # update the innovation using discount
          # model.innovation = model.sysVar * (1 / self.discount - 1)
  
      # when y is missing, then we update the status by the predicted results
      else:
          # we do not update the model.predict.step because we need to take of the case
          # [5, None, None, None]. In such case, we do not add more innovation, because
          # no information is comming in.
          # This is correct because
          # 1. for the first 'None', the step starts from 0 because '5' appears before
          # 2. for the second 'None', the step starts from 1, but the prediction.state
          #    is correct, because now model.state = model.prediciton.state
          # 3. The last 'None' follows the same
  
          model.state = model.prediction.state
          model.sysVar = model.prediction.sysVar
          model.obs = model.prediction.obs
          model.obsVar = model.prediction.obsVar
  
      # recover the evaluation and the transition matrix
      if dealWithMissingEvaluation:
          self._recoverTransitionAndEvaluation(model, loc)
  
file_path: pydlm/pydlm/base/kalmanFilter.py
imports: import numpy
  import pydlm.base.tools
label_desc: Use image node_id 3 for calling the kalmanFilter obj's underlying member method code with example usage: obj.forwardFilter(model, y, dealWithMissingEvaluation) without return types