pykalman: An implementation of the Kalman Filter, Kalman Smoother, and EM algorithm in Python · Pythie
Welcome to pykalman
The dead-simple Kalman Filter, Kalman Smoother, and EM library for Python.
pykalman is a Python library for Kalman filtering and smoothing, providing efficient algorithms for state estimation in time series. It includes tools for linear dynamical systems, parameter estimation, and sequential data modeling. The library supports the Kalman Filter, Unscented Kalman Filter, and EM algorithm for parameter learning.
Originally created by Daniel Duckworth (@duckworthd).
:rocket: Version 0.11.2 out now! Check out the release notes here .
Downloads
:speech_balloon: Where to ask questions Questions and feedback are extremely welcome! We strongly believe in the value of sharing help publicly, as it allows a wider audience to benefit from it.
:hourglass_flowing_sand: Install pykalman
Operating system : macOS X · Linux · Windows 8.1 or higher
Python version : Python 3.10, 3.11, 3.12, 3.13, and 3.14
Package managers : pip
For a quick installation::
Alternatively, you can setup from source:
:zap: Usage from pykalman import KalmanFilter
import numpy as np
kf = KalmanFilter(transition_matrices = [[1, 1], [0, 1]], observation_matrices = [[0.1, 0.5], [-0.3, 0.0]])
measurements = np.asarray([[1,0], [0,0], [0,1]]) # 3 observations
kf = kf.em(measurements, n_iter=5)
(filtered_state_means, filtered_state_covariances) = kf.filter(measurements)
(smoothed_state_means, smoothed_state_covariances) = kf.smooth(measurements)
Also included is support for missing measurements:
from numpy import ma
measurements = ma.asarray(measurements)
measurements[1] = ma.masked # measurement at timestep 1 is unobserved
kf = kf.em(measurements, n_iter=5)
(filtered_state_means, filtered_state_covariances) = kf.filter(measurements)
(smoothed_state_means, smoothed_state_covariances) = kf.smooth(measurements)
And for the non-linear dynamics via the UnscentedKalmanFilter:
from pykalman import UnscentedKalmanFilter
ukf = UnscentedKalmanFilter(lambda x, w: x + np.sin(w), lambda x, v: x + v, transition_covariance=0.1)
(filtered_state_means, filtered_state_covariances) = ukf.filter([0, 1, 2])
(smoothed_state_means, smoothed_state_covariances) = ukf.smooth([0, 1, 2])
And for online state estimation:
for t in range(1, 3):
filtered_state_means[t], filtered_state_covariances[t] = \
kf.filter_update(filtered_state_means[t-1], filtered_state_covariances[t-1], measurements[t])
And for numerically robust "square root" filters
from pykalman.sqrt import CholeskyKalmanFilter, AdditiveUnscentedKalmanFilter
kf = CholeskyKalmanFilter(transition_matrices = [[1, 1], [0, 1]], observation_matrices = [[0.1, 0.5], [-0.3, 0.0]])
ukf = AdditiveUnscentedKalmanFilter(lambda x, w: x + np.sin(w), lambda x, v: x + v, observation_covariance=0.1)
Examples Examples of all of pykalman's functionality can be found here .
Popularity
Downloads, last 7 days 39K-1%
Stars, last 7 days –
Direct dependents 27
All dependents 31 40
Low activity
Maintenance, out of 100
Recent release
last release 301 days ago
Commit activity
0/26 weeks with commits
Release cadence
2 releases in 12 months
Issues & PRs handled
35% closed in the past year
Contributor spread
19 authors in last 100 commits
Releases
Latest 0.11.2
Released Jan 31, 2026
Releases, 12 months 2
First release Aug 20, 2012 Compatibility
Requires Python <3.15,>=3.10
Tested on 3.10 · 3.11 · 3.12 · 3.13 · 3.14
License non-standard (Other)