rlabbe / filterpy

Python Kalman filtering and optimal estimation library. Implements Kalman filter, particle filter, Extended Kalman filter, Unscented Kalman filter, g-h (alpha-beta), least squares, H Infinity, smoothers, and more. Has companion book 'Kalman and Bayesian Filters in Python'.
MIT License
3.31k stars 617 forks source link

How to get (log)likelihood of the measurement after update step? #246

Open derkbreeze opened 3 years ago

derkbreeze commented 3 years ago

Hi Roger, Just have a confusion between line 1180 and line 1132 in kalman_filter.py

def log_likelihood_of(self, z):

""" log likelihood of the measurement z. This should only be called after a call to update(). Calling after predict() will yield an incorrect result."""

    if z is None:
        return log(sys.float_info.min)
    return logpdf(z, dot(self.H, self.x), self.S)
@property

def log_likelihood(self): """ log-likelihood of the last measurement. """ if self._log_likelihood is None: self._log_likelihood = logpdf(x=self.y, cov=self.S) return self._log_likelihood

What do you mean by "log_likelihood of the last measurement" in log_likelihood function? Shouldn't only log_likelihood_of be used to calculate the multivariate normal pdf of measurement z_k at time k? What is the difference between them? Appreciate your clarification.