This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Simple 1D Kalman filters
version 2.0.1
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 2.0.2
Committed At 2017-04-28 16:06:50 UTC
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1




Simple 1D Kalman filters in Elm

kalman filter graph


elm package install CallumJHays/elm-kalman-filter


-- `model.noise` contains 100 gaussian-random numbers generated by
-- elm-community/random-extra: `Random.Float.standardNormal`

xAxis =
    List.Range 0 1000

-- Apply a quadratic function
signal =
    xAxis |> (\x -> 0.001 * (x - 10) ^ 2 - (x - 10))

noisySignal =
    signal |> List.map2 (+) model.noise

predictedSignal : List Float
predictedSignal =
    KalmanFilter.filter Nothing noisySignal

Getting Started

The filter functon is the easiest way to use a Kalman Filter:

predictedSignal : List Float
predictedSignal =
    KalmanFilter.filter Nothing noisySignal

However, it might not be the most appropriate for your use case. For example, if your application recieves rolling updates of a signal from an API server that you need filtered, it would be more appropriate to keep a copy of KalmanFilter.Model in your application Model, and to use it along with KalmanFilter.filterMeasurement to provide less noisy signals as they come in.

One great concrete use-case for usage with an API server is multiplayer video- games that require a mechanism for preventing Rubber-banding. The Kalman filter may be used without smoothing to observe the values being passed in (using filter with the Param.expectedNoisePower parameter set to 0). Backup values can then be provided in durations when the network lags using predictNext. Of course, this use-case would be far more relevant if this library was generalised to N-Dimensional data (2D, 3D) - but that's still a work in progress :)