https://github.com/oseiskar/simdkalman
Python Kalman filters vectorized as Single Instruction, Multiple Data
https://github.com/oseiskar/simdkalman
kalman-filter python
Last synced: about 1 year ago
JSON representation
Python Kalman filters vectorized as Single Instruction, Multiple Data
- Host: GitHub
- URL: https://github.com/oseiskar/simdkalman
- Owner: oseiskar
- License: mit
- Created: 2017-11-18T20:32:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-16T08:23:09.000Z (over 2 years ago)
- Last Synced: 2025-03-28T15:11:21.538Z (about 1 year ago)
- Topics: kalman-filter, python
- Language: Python
- Homepage: https://simdkalman.readthedocs.io/
- Size: 163 KB
- Stars: 184
- Watchers: 12
- Forks: 39
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# SIMD Kalman
[](http://simdkalman.readthedocs.io/en/latest/?badge=latest)
[](https://pypi.python.org/pypi/simdkalman)
[](https://pypi.python.org/pypi/simdkalman)
Fast Kalman filters in Python leveraging single-instruction multiple-data
vectorization. That is, running _n_ similar Kalman filters on _n_
independent series of observations. Not to be confused with SIMD processor
instructions.
```python
import simdkalman
kf = simdkalman.KalmanFilter(
state_transition = np.array([[1,1],[0,1]]),
process_noise = np.diag([0.1, 0.01]),
observation_model = np.array([[1,0]]),
observation_noise = 1.0)
data = numpy.random.normal(size=(200, 1000))
# smooth and explain existing data
smoothed = kf.smooth(data)
# predict new data
pred = kf.predict(data, 15)
```
See `examples/example.py` for a more comprehensive example and
[ReadTheDocs](https://simdkalman.readthedocs.io/) for the full documentation.
For the changelog, see [releases page](https://github.com/oseiskar/simdkalman/releases)
According to `examples/benchmark.py`. This can be up to **100x faster** than
[pykalman](https://pykalman.github.io/) and **70x faster** than
[filterpy](https://github.com/rlabbe/filterpy) when can be vectorized over
many independent timeseries. Also in the non-vectorized case, it can be 2x
faster.
### Installation
pip install simdkalman
### Development
1. Create virtualenv
* Python 2: `virtualenv venvs/python2`
* Python 3: `python3 -m venv venvs/python3`
1. Activate virtualenv: `source venvs/pythonNNN/bin/activate`
1. Install locally `pip install -e .[dev,test,docs]`
1. `./run-tests.sh`
1. `deactivate` virtualenv
### Distribution
(personal howto)
Once:
1. create an account in https://testpypi.python.org/pypi and
https://pypi.python.org/pypi
1. create `~/.pypirc` as described [here](https://packaging.python.org/guides/migrating-to-pypi-org)
1. `sudo pip install twine`
1. create testing virutalenvs:
* `virtualenv venvs/test-python2`
* `python3 -m venv venvs/test-python3`
Each distribution:
# first, set version in setup.py
# then, download the wheel.zip artifact from Github and extract it to dist/
# or create it manually: python setup.py bdist_wheel
# test PyPI site
twine upload --repository testpypi dist/simdkalman-VERSION*
# the real thing
twine upload dist/simdkalman-VERSION*
# update git tags
git tag VERSION -m "released VERSION"
git push --tags
Test installation from the test site with
source venvs/test-pythonNNN/bin/activate
pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
simdkalman --upgrade
# or the real thing with just
# pip install simdkalman
pip install matplotlib
python examples/example.py
deactivate