Copyright 2015 Roger R Labbe Jr.

FilterPy library.

Documentation at:

Supporting book at:

This is licensed under an MIT license. See the readme.MD file for more information., order=2)[source]

Computes values for g and h (and k for g-h-k filter) for a critically damped filter.

The idea here is to create a filter that reduces the influence of old data as new data comes in. This allows the filter to track a moving target better. This goes by different names. It may be called the discounted least-squares g-h filter, a fading-memory polynomal filter of order 1, or a critically damped g-h filter.

In a normal least-squares filter we compute the error for each point as

\[\epsilon_t = (z-\hat{x})^2\]

For a crically damped filter we reduce the influence of each error by



\[0 <= \theta <= 1\]

In other words the last error is scaled by theta, the next to last by theta squared, the next by theta cubed, and so on.

theta : float, 0 <= theta <= 1

scaling factor for previous terms

order : int, 2 (default) or 3

order of filter to create the parameters for. g and h will be calculated for the order 2, and g, h, and k for order 3.

g : scalar

optimal value for g in the g-h or g-h-k filter

h : scalar

optimal value for h in the g-h or g-h-k filter

k : scalar

optimal value for g in the g-h-k filter


Brookner, “Tracking and Kalman Filters Made Easy”. John Wiley and Sons, 1998.

Polge and Bhagavan. “A Study of the g-h-k Tracking Filter”. Report No. RE-CR-76-1. University of Alabama in Huntsville. July, 1975


from import GHFilter, critical_damping_parameters

g,h = critical_damping_parameters(0.3)
critical_filter = GHFilter(0, 0, 1, g, h)