# critical_damping_parameters

Copyright 2015 Roger R Labbe Jr.

FilterPy library. http://github.com/rlabbe/filterpy

Documentation at: https://filterpy.readthedocs.org

Supporting book at: https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python

This is licensed under an MIT license. See the readme.MD file for more information.

filterpy.gh.critical_damping_parameters(theta, order=2)

  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

  > \[\theta^{t-i}\]

  where

  > \[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.

  Parameters:
    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.

  Returns:
    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

  References

  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

  Examples

      from filterpy.gh import GHFilter, critical_damping_parameters

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