Kalman Filter textbook using Ipython Notebook. This book takes a minimally mathematical approach, focusing on building intuition and experience, not formal proofs. Includes Kalman filters, Extended Kalman filters, unscented filters, and more. Includes exercises with solutions.
rlabbe on master
added space after operator Exa… (compare)
rlabbe on master
Issue #420 - Clarify sum is of … (compare)
rlabbe on master
switch to f-strings Some cells… (compare)
rlabbe on master
interactive plots now work corr… merged and resolved conflicts Merge branch 'deadundead-fix-in… and 1 more (compare)
rlabbe on master
Reordered plot for consistency … Merge pull request #415 from er… (compare)
rlabbe on master
Update 11-Extended-Kalman-Filte… Merge pull request #402 from jd… (compare)
rlabbe on master
Update 11-Extended-Kalman-Filte… Merge pull request #362 from Ni… (compare)
rlabbe on master
Proof reading Chapter 5 Fixed … Proof reading Chapter 5 Remove… Proof reading Chapter 9 No cha… and 7 more (compare)
rlabbe on master
Elaborate how c_0=x_0 Merge pull request #403 from Ac… (compare)
rlabbe on master
Update README.md Removed the l… Merge pull request #384 from nb… (compare)
rlabbe on master
Minor typo Merge pull request #419 from bi… (compare)
rlabbe on master
Update README.md Spelling erro… Merge pull request #409 from ac… (compare)
rlabbe on master
Fix minor typo Merge pull request #388 from ca… (compare)
rlabbe on master
Fix typo in markdown Typo in c… Merge pull request #387 from si… (compare)
rlabbe on master
docs: Fix a few typos There ar… Merge pull request #385 from ti… (compare)
rlabbe on master
:pencil: Fixed duplicated of of… :pencil: Fixed duplicated of of… Merge pull request #375 from Gj… (compare)
rlabbe on master
Add the missing letter <T> on t… Fix a typo Merge branch 'rlabbe:master' in… and 1 more (compare)
rlabbe on master
fix: small error Merge pull request #374 from 0x… (compare)
rlabbe on master
add plural s typo, wording fix typos and 1 more (compare)
rlabbe on master
Fix typos Merge pull request #368 from dr… (compare)
%matplotlib inline
to %matplotlib notebook
and the figure became interactive! I could rotate the PDF to see more angles.
plot_estimate_chart_3()
, the residual line is black and is hard to see. I updated my local copy to make it green, though something brighter like magenta could be better. Change line 107 of code/gh_internal.py
:ax.annotate('', xy=[1,159], xytext=[1,164.2], arrowprops=dict(arrowstyle='-', ec='g', lw=1, shrinkA=8, shrinkB=8))
Hi. Those are good additions for the library. Here's the current status:
Missing data is handled by setting z=None. If using batch_filter, you might call it with kf.batch_filter(zs=[1., 2., 3., None, 5.]). That is probably not 'canonical' python behavior, and I will add it to the issues.
I am working on log-likelihood, and metrics like NEES, NIS, etc for the next release of FilterPy.
I do not currently have an SVD filter. It is on the backlog.
The Kalman filter class uses the standard linear Kalman filter equations; this makes it more pedagogical in nature, though I have used it plenty of times in less demanding situations. The only concession I made to real world engineering is in the computation of P - the published (I-KH)P equation is unstable.
A square root filter is implemented by the class SquareRootKalmanFilter, in the filterpy.kalman module. Read the documentation carefully - this is more a reference implementation and i have not used it in production. Brown suggests that square root filters are no longer needed with modern hardware unless P is going to vary by 20 orders of magnitude. His reasoning seems strong, but I do not have empirical evidence to back that up.
To round out the descriptions, there is also a fading memory and information filter implemented for the linear filters. I have an EKF and UKF, but not with the square root variants.
If you want to compute the log-likelihood yourself you can. This link gives the equation for the computation: http://www.econ.umn.edu/~karib003/help/kalman_example1.htm. Their 'C_t' can be accessed with 'kf.S' in my code after calling update().
import numpy as np
from scipy.stats import multivariate_normal
from numpy import dot, log, exp
import scipy.linalg as la
def gaus_pdf(X, M, S):
DX = (X-M)[0,0]
E = 0.5*np.dot(DX.T, (S/DX))
d = M.shape[0]
E = E + 0.5 * d * log(2*np.pi) + 0.5 * log(la.det(S));
P = exp(-E)
return P
def kf_liklihood(x, P, z, H, R):
IM = np.dot(H, x)
S = np.dot(H, P).dot(H.T) + R
print(gaus_pdf(z, IM, S))
print(multivariate_normal.pdf(z, mean=IM, cov=S))
return multivariate_normal.pdf(z, mean=IM, cov=S)
from scipy.stats import multivariate_normal
def likelihood(x, P, z, H, R):
IM = np.dot(H, x)
S = np.dot(H, P).dot(H.T) + R
return multivariate_normal.pdf(z, mean=IM, cov=S)
FilterPy 0.0.26 changes:
Added likelihood and log-likelihood to the KalmanFilter
class.
Added an MMAE filter bank class.
Added function to compute NEES
When I install the packge filterpy，I got the following error:
C:\WINDOWS\system32>conda install --channel https://conda.anaconda.org/phios filterpy
Fetching package metadata: ......
Solving package specifications: ..........
Error: Unsatisfiable package specifications.
Generating hint:
[ COMPLETE ]|##################################################| 100%
Hint: the following packages conflict with each other:
Use 'conda info filterpy' etc. to see the dependencies for each package.
Note that the following features are enabled:
pip install filterpy
instead; that should work. Recently I tried to get filterpy working with conda; conda install filterpy
might work for windows, but I have reports it doesn't work for mac and linux yet. I need to put more effort on this.