least_squares_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.least_squares_parameters(n)[source]

An order 1 least squared filter can be computed by a g-h filter by varying g and h over time according to the formulas below, where the first measurement is at n=0, the second is at n=1, and so on:

\[ \begin{align}\begin{aligned}h_n = \frac{6}{(n+2)(n+1)}\\g_n = \frac{2(2n+1)}{(n+2)(n+1)}\end{aligned}\end{align} \]
Parameters:
n : int

the nth measurement, starting at 0 (i.e. first measurement has n==0)

Returns:
(g,h) : (float, float)

g and h parameters for this time step for the least-squares filter

Examples

from filterpy.gh import GHFilter, least_squares_parameters

lsf = GHFilter (0, 0, 1, 0, 0)
z = 10
for i in range(10):
    g,h = least_squares_parameters(i)
    lsf.update(z, g, h)