Skip to content

RLS and the Kalman filter

RLS solves least squares again at every sample, so it learns fast; the Kalman filter predicts with a model and corrects with measurements.

Before this26.3 · 5 more
Chapter 26 · Lesson 4 of 4

First, the picture

Two adaptive filters learn the same 8-tap system from a strongly coloured input: the LMS of 26.3, and RLS. The curves show how far each one’s taps still are from the answer. Watch how early the RLS curve drops: after 50 samples it is at −40.7 dB, while LMS has barely moved.

RLS arrives in a few steps

Identifying 8 taps from a coloured input (seeds 264 and 2640; input power 0.990, noise RMS 0.0100); RLS γ = 0.999, LMS μ = 0.02.

One sample in: both start near 0 dB, the taps far from the answer.

n
1
LMS
−0.2 dB
RLS
−4.0 dB
0.00 / 14.00 s
Describe this picture

One panel: identifying 8 taps from a coloured input (seeds 264 and 2640; input power 0.990, noise RMS 0.0100), with RLS at γ = 0.999 and LMS at μ = 0.02. The misalignment, from −70 to 5 dB, is plotted against sample nn from 1 to 2000 on a logarithmic axis, so the early samples get as much room as the late ones. Both curves are solid lines, labelled “LMS” and “RLS” at their right ends and drawn up to the current sample; the LMS curve ends in a square and the RLS curve in a dot. The readouts are nn and the two misalignments in dB. One sample in, both start near 0 dB: −0.2 dB for LMS and −4.0 dB for RLS. At 50 samples RLS is already at −40.7 dB, and LMS has barely moved, −1.7 dB. At 2000 samples LMS has crawled to −47.1 dB, and RLS sits at −56.1 dB, a floor set by the noise.

RLS arrives in a few steps

In Adaptive filters: LMS (26.3), LMS learned the taps of an unknown system one small step at a time. Each step used the slope from a single sample. A coloured input made it crawl along the flat directions of the error bowl.

Think of a set of equations. You can solve them outright, or you can improve a guess a little at a time. LMS improves a guess. Recursive least squares, or RLS, solves outright at every new sample, and it does so cheaply.

This page is marked advanced because it works with matrices. From linear algebra I use only three things. They are a matrix times a vector, the transpose ⊤^\top that turns a column into a row, and the inverse of a matrix, which undoes it.

Least squares over the past

The setting is 26.3’s system identification. An unknown FIR system is driven by an input x[n]x[n], and its output plus a little white noise v[n]v[n] is the desired signal ddes[n]d_\text{des}[n]. My filter has NhN_h taps in a column h\mathbf{h}. At sample nn it sees the tap-input vector xn=(x[n],…,x[n−Nh+1])⊤\mathbf{x}_n=(x[n],\dots,x[n-N_h+1])^\top, newest first, as in 26.3.

In “Least squares or least worst” of Optimal FIR design (19.3), the least-squares design made the mean square of the error as small as possible. RLS does the same with the errors of every sample so far, added up. I count samples from n=1n=1 on this page, and I give old errors less weight. After nn samples, the taps should make this sum as small as possible:

∑i=1nγ n−i(ddes[i]−h⊤xi)2.\sum_{i=1}^{n}\gamma^{\,n-i}\big(d_\text{des}[i]-\mathbf{h}^\top\mathbf{x}_i\big)^2.

The number γ\gamma is the forgetting factor, just below 1. It has no argument, so it is not 19.3’s weight γ(Ω)\gamma(\Omega). An error kk samples old counts γk\gamma^k times as much as the newest one. With γ=0.999\gamma=0.999, an error 1000 samples old counts 0.368 times, so RLS remembers roughly the last 1/(1−γ)=10001/(1-\gamma)=1000 samples.

Why forget at all? If the unknown system changes slowly, old samples describe a system that is gone. Forgetting lets RLS follow it.

In “The best FIR filter, from correlations” of The Wiener filter (26.2), the best taps solved the Wiener–Hopf equations Rh=r\mathbf{R}\mathbf{h}=\mathbf{r}, built from expected values. Setting the slope of the sum above to zero along each tap gives the same equations, with weighted sums of the data in place of expected values:

Rn=∑i=1nγ n−i xixi⊤,rn=∑i=1nγ n−i ddes[i] xi.\begin{aligned} \mathbf{R}_n&=\sum_{i=1}^{n}\gamma^{\,n-i}\,\mathbf{x}_i\mathbf{x}_i^\top,\\ \mathbf{r}_n&=\sum_{i=1}^{n}\gamma^{\,n-i}\,d_\text{des}[i]\,\mathbf{x}_i. \end{aligned}

The best taps after nn samples, hn\mathbf{h}_n, solve Rnhn=rn\mathbf{R}_n\mathbf{h}_n=\mathbf{r}_n.

Solving these afresh at every sample would cost on the order of Nh3N_h^3 operations each time. But the new matrix is the old one, scaled, plus one piece: Rn=γRn−1+xnxn⊤\mathbf{R}_n=\gamma\mathbf{R}_{n-1}+\mathbf{x}_n\mathbf{x}_n^\top. So RLS keeps the inverse, Pn=Rn−1\mathbf{P}_n=\mathbf{R}_n^{-1}, and updates it with that one piece. Here are the four lines it runs at each sample:

gn=Pn−1xnγ+xn⊤Pn−1xn,e[n]=ddes[n]−hn−1⊤xn,hn=hn−1+gn e[n],Pn=1γ(Pn−1−gnxn⊤Pn−1).\begin{aligned} \mathbf{g}_n&=\frac{\mathbf{P}_{n-1}\mathbf{x}_n}{\gamma+\mathbf{x}_n^\top\mathbf{P}_{n-1}\mathbf{x}_n},\\ e[n]&=d_\text{des}[n]-\mathbf{h}_{n-1}^\top\mathbf{x}_n,\\ \mathbf{h}_n&=\mathbf{h}_{n-1}+\mathbf{g}_n\,e[n],\\ \mathbf{P}_n&=\tfrac{1}{\gamma}\big(\mathbf{P}_{n-1}-\mathbf{g}_n\mathbf{x}_n^\top\mathbf{P}_{n-1}\big). \end{aligned}

The first line is the gain gn\mathbf{g}_n, a column of NhN_h numbers. The second is the error made with the old taps. The third moves the taps by the gain times that error. The last updates the inverse without inverting anything, and the linear algebra callout further on names the trick.

Before the first sample I start from h0=0\mathbf{h}_0=\mathbf{0} and P0=100 I\mathbf{P}_0=100\,\mathbf{I}. That P0\mathbf{P}_0 is the inverse of 0.01 I0.01\,\mathbf{I}, a tiny made-up correlation that stands in until data arrive. It adds a small extra term to the sum, so the first solutions exist, and that term shrinks as γn\gamma^n. Apart from it, hn\mathbf{h}_n is the exact least-squares answer at every nn.

Now compare the steps. LMS moves its taps along μxn\mu\mathbf{x}_n. RLS moves them along gn\mathbf{g}_n, which is Pn−1xn\mathbf{P}_{n-1}\mathbf{x}_n divided by a number.

Because P\mathbf{P} is the inverse of the correlation matrix, it stretches the step along the bowl’s flat directions by as much as the input’s colour squeezed them. So every direction is learned at one pace, whatever the colour.

The task

Let’s give both the same job. The unknown system has 8 taps, htrue[k]=0.8kcos⁡(0.4πk)h_\text{true}[k]=0.8^k\cos(0.4\pi k) for k=0k=0 to 7. They are 1.000, 0.247, −0.518, −0.414, 0.127, 0.328, 0.081 and −0.170.

The input is AR(1) noise, as in Random processes (24.2): each value is 0.9 times the last plus a new white Gaussian draw. The draws have variance 0.19 (seed 264), and the first 300 outputs are dropped. That variance makes the input’s power 0.19/(1−0.92)=10.19/(1-0.9^2)=1; this draw measures 0.990.

The noise v[n]v[n] has standard deviation σv=0.01\sigma_v=0.01 (seed 2640) and measures RMS 0.0100.

This input is strongly coloured. Its correlation matrix R\mathbf{R} has the entries 0.9∣i−k∣0.9^{\lvert i-k\rvert}, and its eigenvalues run from 0.055 to 6.20, a spread of 113. In 26.3’s bowl the spread was 4.0.

LMS gets the step size μ=0.02\mu=0.02, the μ\mu of 26.3. Here tr⁡R\operatorname{tr}\mathbf{R}, the trace, adds up the diagonal, so it is 8. A common safe bound for LMS is 2/tr⁡R=0.2502/\operatorname{tr}\mathbf{R}=0.250, below 26.3’s 2/λmax=0.3222/\lambda_\text{max}=0.322, and μ\mu sits well under it. RLS gets γ=0.999\gamma=0.999.

To measure how far the taps are from the answer, I use the misalignment, in decibels:

∥hn−htrue∥2∥htrue∥2.\frac{\lVert\mathbf{h}_n-\mathbf{h}_\text{true}\rVert^2}{\lVert\mathbf{h}_\text{true}\rVert^2}.

Here ∥h∥2\lVert\mathbf{h}\rVert^2 is the sum of the squares of the entries. At 0 dB the error is as large as the answer itself. At −30 dB its squared size is a thousandth of the answer’s.

The picture at the top of the page plots this misalignment for both filters. After 2000 samples LMS has crawled to −47.1 dB, and RLS sits at −56.1 dB, a floor set by the noise.

Notice how early RLS drops. After 8 samples it has 8 equations for its 8 unknowns, and it is at −33.3 dB. After 16 samples it is at −33.7 dB, while LMS is at −0.8 dB.

LMS is slow for the reason 26.3 gave. Each direction of the bowl shrinks by 1−μλ1-\mu\lambda per step, so the flattest one, with λmin=0.055\lambda_\text{min}=0.055, has the time constant 1/(μλmin)1/(\mu\lambda_\text{min}), about 914 samples. LMS first gets below −30 dB at sample 917.

What RLS costs

RLS is not free. Count the multiplications in its four lines, treating a division as a multiplication. Pn−1xn\mathbf{P}_{n-1}\mathbf{x}_n takes Nh2N_h^2. P\mathbf{P} is symmetric, so xn⊤Pn−1\mathbf{x}_n^\top\mathbf{P}_{n-1} is the same numbers as a row, and xn⊤Pn−1xn\mathbf{x}_n^\top\mathbf{P}_{n-1}\mathbf{x}_n needs NhN_h more.

The gain takes NhN_h divisions, the error NhN_h products and the taps NhN_h. The new Pn\mathbf{P}_n takes Nh2N_h^2 products and Nh2N_h^2 divisions by γ\gamma. That is 3Nh2+4Nh3N_h^2+4N_h, which is 224 for 8 taps.

LMS needs NhN_h for its output, 1 for μe[n]\mu e[n] and NhN_h for the taps: 2Nh+1=172N_h+1=17. So RLS costs about 13 times as much per sample here, and the ratio grows with NhN_h.

Is the colour really the culprit? Give LMS a white input of the same nominal power (seed 2641, measured 1.017) and the same noise. It gets below −30 dB after 150 samples instead of 917, and RLS needs 10 there, against 8 with the coloured input. The colour, not the task, slows LMS.

The forgetting factor sets RLS’s floor. With a memory of about 1000 samples, the noise never quite averages away. Theory puts the floor at 1−γ2 σv2tr⁡R−1/∥htrue∥2\tfrac{1-\gamma}{2}\,\sigma_v^2\operatorname{tr}\mathbf{R}^{-1}/\lVert\mathbf{h}_\text{true}\rVert^2, which is −56.9 dB here, and the clip ends at −56.1 dB. A smaller γ\gamma follows a changing system sooner, but sits on a higher floor.

Predict, then correct

Now a different problem in the same spirit. A target moves in a plane, and every 0.1 s a sensor reports its position with an error of a few metres. I want its true path.

A ship’s navigator works this way. Between fixes, they work out the position from the last one, the speed and the heading; this is dead reckoning. Each new fix nudges that estimate: more if the fix is reliable, less if it is rough.

A model of the motion

In “What is stored, and what is pushed in” of Difference equations (6.1), the stored value was what a system carries from one sample to the next. For a moving target I carry the position and the velocity, and I call them the state. I treat the two axes separately. Along each axis the state is the column sn=(position,velocity)⊤\mathbf{s}_n=(\text{position},\text{velocity})^\top at time nTsnT_s, with Ts=0.1T_s=0.1 s.

In one step, the position moves on by TsT_s times the velocity, and the velocity stays the same. In matrix form that is Asn−1\mathbf{A}\mathbf{s}_{n-1}, with

A=(1Ts01).\mathbf{A}=\begin{pmatrix}1&T_s\\0&1\end{pmatrix}.

Nothing steers the target, but a random acceleration jostles it, new at each step, with standard deviation σa=0.3\sigma_a=0.3 m/s². Over one step it adds Ts2/2T_s^2/2 times that acceleration to the position and TsT_s times it to the velocity. This is the constant-velocity model: the velocity stays constant apart from those random pushes.

How big is a push? In “A cloud that leans: correlation” of Random variables for signals (24.1), the top of the correlation coefficient was E{(x−μx)(y−μy)}\mathbb{E}\{(x-\mu_x)(y-\mu_y)\}. That average is the covariance of the two values.

Put the variances on the diagonal of a matrix and the covariances off it, and you have a covariance matrix. The push’s is

Q=σa2(Ts4/4Ts3/2Ts3/2Ts2),\mathbf{Q}=\sigma_a^2\begin{pmatrix}T_s^4/4&T_s^3/2\\T_s^3/2&T_s^2\end{pmatrix},

because each entry is a product of two of the push’s parts, Ts2/2T_s^2/2 and TsT_s, times the acceleration’s variance.

The sensor measures the position only, with white noise v[n]v[n] of standard deviation σv\sigma_v:

y[n]=c⊤sn+v[n],c⊤=(1, 0).y[n]=\mathbf{c}^\top\mathbf{s}_n+v[n],\qquad\mathbf{c}^\top=(1,\ 0).

The row c⊤\mathbf{c}^\top picks the position out of the state. Along the x axis σv\sigma_v is 3 m, and along the y axis 1.5 m.

This is a state-space model: one equation for how the state moves, and one for what the sensor sees. The page assumes the model is right, and that the push and the sensor noise are Gaussian with known sizes.

Predict, then update

The Kalman filter keeps an estimate of the state, which I also write sn\mathbf{s}_n, and the covariance matrix Pn\mathbf{P}_n of that estimate’s error: its own uncertainty. RLS’s Pn\mathbf{P}_n measured the same kind of thing, how unsure the taps were.

At each new time it does two things. Predict: run the model forward without a push, and grow the uncertainty by the push’s covariance. A minus sign up high marks a prediction:

sn−=Asn−1,Pn−=APn−1A⊤+Q.\begin{aligned} \mathbf{s}_n^-&=\mathbf{A}\mathbf{s}_{n-1},\\ \mathbf{P}_n^-&=\mathbf{A}\mathbf{P}_{n-1}\mathbf{A}^\top+\mathbf{Q}. \end{aligned}

Update: compare the measurement with the predicted position. The difference y[n]−c⊤sn−y[n]-\mathbf{c}^\top\mathbf{s}_n^- is the innovation, the part of the measurement the model did not expect. Move the estimate by a fraction of it, set by the Kalman gain gn\mathbf{g}_n:

gn=Pn−cc⊤Pn−c+σv2,sn=sn−+gn(y[n]−c⊤sn−),Pn=Pn−−gnc⊤Pn−.\begin{aligned} \mathbf{g}_n&=\frac{\mathbf{P}_n^-\mathbf{c}}{\mathbf{c}^\top\mathbf{P}_n^-\mathbf{c}+\sigma_v^2},\\ \mathbf{s}_n&=\mathbf{s}_n^-+\mathbf{g}_n\big(y[n]-\mathbf{c}^\top\mathbf{s}_n^-\big),\\ \mathbf{P}_n&=\mathbf{P}_n^--\mathbf{g}_n\mathbf{c}^\top\mathbf{P}_n^-. \end{aligned}

Why that gain? Write P11−P^-_{11} for the top-left entry of Pn−\mathbf{P}_n^-, the variance of the predicted position. The gain’s first entry, for the position, is P11−/(P11−+σv2)P^-_{11}/(P^-_{11}+\sigma_v^2).

If the prediction is much surer than the sensor, it is near 0, and the filter keeps its prediction. If the sensor is much surer, it is near 1, and the filter jumps to the measurement. In between, each is weighted by how sure it is.

The gain’s second entry moves the velocity, which no sensor measures: the filter learns it from how the positions drift.

Under the page’s assumptions, no other estimate made from the measurements so far has a smaller mean-square error. That is the sense in which R. E. Kalman’s filter, from his paper of 1960, is the optimal recursive estimator.

I start from the first measurement with zero velocity, s0=(y[0], 0)⊤\mathbf{s}_0=(y[0],\ 0)^\top, and from P0=diag(σv2,100)\mathbf{P}_0=\mathrm{diag}(\sigma_v^2,100), where diag\mathrm{diag} puts its numbers on the diagonal and zeros elsewhere. The 100 says I have little idea of the velocity: a standard deviation of 10 m/s.

The uncertainty ellipse

Along one axis, write P11P_{11} for the top-left entry of Pn\mathbf{P}_n. Then P11\sqrt{P_{11}} is the standard deviation of the position error. With both axes, I draw an uncertainty ellipse around the estimate, reaching the x filter’s 2P112\sqrt{P_{11}} along x and the y filter’s along y. Its axes lie along x and y because the two filters run independently.

Picture 24.1’s cloud of Gaussian pairs with independent coordinates, and draw around it the ellipse two standard deviations out along each axis: it holds 86.5 % of the draws. So if the filter is honest, the true position should lie inside its ellipse about 86.5 % of the time.

Here is the run. The target starts at the origin with velocity (1.0, 0.5) m/s and follows the model above. Its random accelerations come from seed 2642, with σa=0.3\sigma_a=0.3 m/s²; their unit draws measure standard deviation 1.024.

The sensor’s noise is 3 m along x and 1.5 m along y (seed 2643), and measures 3.095 m and 1.518 m. The filter knows the model and those sizes, and runs once per axis for 30 s.

Predict, then correct

30 s of a randomly accelerating target (seed 2642), measured every 0.1 s with noise of 3 m along x and 1.5 m along y (seed 2643; measured 3.095 and 1.518).

The first measurement is the first estimate; the ellipse, ±6.00 m by ±3.00 m, is two measurement standard deviations.

time
0.0 s
ellipse
±6.00 m, ±3.00 m
RMS error so far: measured, estimate
6.05 m, 6.05 m
0.00 / 20.00 s
Describe this picture

One panel at equal scales: 30 s of a randomly accelerating target (seed 2642), measured every 0.1 s with noise of 3 m along x and 1.5 m along y (seed 2643; measured 3.095 and 1.518). The axes run from −10 to 35 m along x and from −5 to 20 m along y. The true path is a dashed line and the measurements small dots. The Kalman estimate is a solid line, with a filled dot at the current estimate and the ellipse drawn around it as an outline. Each is drawn up to the current time, and a key names the four. Each step plays in two halves: the estimate moves on to its prediction and the ellipse grows, then the new dot appears and the estimate moves toward it as the ellipse shrinks. The readouts are the time, the ellipse’s reach along x and along y, and the RMS distance from the true position so far, of the dots and of the estimate. At time 0 the first measurement is the first estimate, and the ellipse, ±6.00 m by ±3.00 m, is two measurement standard deviations; both RMS errors read 6.05 m. At 3 s the ellipse has shrunk to ±2.10 m by ±1.06 m, and the errors read 3.65 m and 1.56 m. At 29.9 s the estimate’s RMS error is 0.96 m against the measurements’ 3.45 m, and the ellipse holds steady at ±1.25 m by ±0.74 m.

Each step plays in two halves, predict then correct: the ellipse grows, then shrinks as the estimate moves toward the new dot. By 29.9 s the estimate’s RMS error is 0.96 m, against the measurements’ 3.45 m.

Watch the ellipse shrink and then hold. It settles at ±1.25 m along x and ±0.74 m along y. Two measurement standard deviations are ±6 m and ±3 m, so the estimate is about four to five times surer than any single dot.

From 5 s on, once the start has been forgotten, the true position lay inside the ellipse 84.4 % of the time: 211 of 250 times. That is close to the Gaussian’s 86.5 %. The ellipse means what it says because the model is right. Over the same span the dots miss by RMS 3.45 m, and the estimate by 0.88 m.

The gains settle too: 0.044 along x and 0.061 along y. So each new dot moves the predicted position 4.4 % of the way toward it along x, and 6.1 % along y. The y sensor is twice as precise, so the filter believes it more.

RLS is a Kalman filter

Look back at RLS with this in mind. Let the state be the taps, with the model “the taps do not move”: A=I\mathbf{A}=\mathbf{I} and no push.

Let the measurement be ddes[n]d_\text{des}[n], with the row xn⊤\mathbf{x}_n^\top in place of c⊤\mathbf{c}^\top and a measurement-noise variance of 1. Let each prediction divide P\mathbf{P} by γ\gamma. Then the Kalman filter’s update is RLS’s four lines.

The forgetting factor plays the part of the push: it makes the filter a little less sure at every step, so the taps can still move.

The maths behind it · the matrix inversion lemma

RLS never inverts Rn\mathbf{R}_n. Adding one piece xnxn⊤\mathbf{x}_n\mathbf{x}_n^\top to a matrix changes its inverse by one piece too, and the matrix inversion lemma (Sherman–Morrison) says which: the gnxn⊤Pn−1\mathbf{g}_n\mathbf{x}_n^\top\mathbf{P}_{n-1} in RLS’s last line. The Kalman update of Pn\mathbf{P}_n is the same kind of one-piece correction, applied to a covariance.

The maths behind it · Bayesian updating

The Kalman filter is Bayesian updating for Gaussians. The prediction is the prior, the measurement the likelihood, and the update the posterior. The gain is the weight that combines two estimates by their variances.

Worked example

1. One Kalman step by hand. Take the tracker’s x axis, so σv=3\sigma_v=3 m and P0=diag(9,100)\mathbf{P}_0=\mathrm{diag}(9,100). The first two measurements are y[0]=3.86y[0]=3.86 m and y[1]=−2.79y[1]=-2.79 m; the true positions are 0 and 0.10 m. So s0=(3.86, 0)⊤\mathbf{s}_0=(3.86,\ 0)^\top.

Predict, ignoring Q\mathbf{Q}, which is tiny. The position moves on by 0.1×00.1\times0, so s1−=(3.86, 0)⊤\mathbf{s}_1^-=(3.86,\ 0)^\top. The top-left entry of AP0A⊤\mathbf{A}\mathbf{P}_0\mathbf{A}^\top is 9+2⋅0.1⋅0+0.01⋅100=109+2\cdot0.1\cdot0+0.01\cdot100=10, and the entry below it is 0.1⋅100=100.1\cdot100=10. With Q\mathbf{Q} the first is 10.00000225.

The gain is (10, 10)⊤/(10+9)(10,\ 10)^\top/(10+9), so both entries are 0.526: the new estimate moves about half of the way to the new measurement. The innovation is −2.79−3.86=−6.65-2.79-3.86=-6.65 m. The position becomes 3.86+0.526×(−6.65)=0.363.86+0.526\times(-6.65)=0.36 m, and the velocity 0+0.526×(−6.65)=−3.500+0.526\times(-6.65)=-3.50 m/s.

The position variance falls to 10−0.526×10=4.7410-0.526\times10=4.74, so the ellipse reaches 24.74=4.352\sqrt{4.74}=4.35 m along x, down from 6.00 m. The velocity is far off, since the truth is about 1.0 m/s. Its variance is still 94.7, so the filter knows it is unsure, and the next measurements fix it.

2. RLS against LMS, counted in work. RLS gets below −30 dB after 8 samples at 224 multiplications each, 8×224=17928\times224=1792 in all, and LMS after 917 samples at 17 each, 917×17=15 589917\times17=15\,589. So even in total work, RLS gets there about 8.7 times cheaper here. With the white input, LMS needs 150×17=2550150\times17=2550, still more than RLS.

Where you’ll meet this

GPS receivers and inertial navigation blend a motion model with noisy fixes in a Kalman filter. Radar trackers do the same for each target they follow, as in Radar signal processing (33.1). Robots use Kalman filters to estimate where they are, and economists use state-space models for quantities they cannot measure directly. A Kalman filter helped navigate the Apollo spacecraft to the Moon.

Real targets turn and brake, and many sensors are not linear in the state. The extended and unscented Kalman filters handle such nonlinear models; this page only names them.

RLS fits where the filter is short and must learn fast, such as some adaptive equalisers in Channels and equalisation (33.2). For long filters, such as echo cancellers with hundreds of taps, its Nh2N_h^2 cost is why LMS and NLMS remain the usual choice.

Reference card

QuantityFormulaNotes
RLS gaingn=Pn−1xn/(γ+xn⊤Pn−1xn)\mathbf{g}_n=\mathbf{P}_{n-1}\mathbf{x}_n/(\gamma+\mathbf{x}_n^\top\mathbf{P}_{n-1}\mathbf{x}_n)γ just below 1
RLS updatehn=hn−1+gne[n]\mathbf{h}_n=\mathbf{h}_{n-1}+\mathbf{g}_ne[n]e[n]=ddes[n]−hn−1⊤xne[n]=d_\text{des}[n]-\mathbf{h}_{n-1}^\top\mathbf{x}_n
Inverse updatePn=(Pn−1−gnxn⊤Pn−1)/γ\mathbf{P}_n=(\mathbf{P}_{n-1}-\mathbf{g}_n\mathbf{x}_n^\top\mathbf{P}_{n-1})/\gammaPn=Rn−1\mathbf{P}_n=\mathbf{R}_n^{-1}
RLS cost3Nh2+4Nh3N_h^2+4N_h per sampleLMS: 2Nh+12N_h+1
Memoryabout 1/(1−γ)1/(1-\gamma) samples1000 at γ = 0.999
Misalignment∥hn−htrue∥2/∥htrue∥2\lVert\mathbf{h}_n-\mathbf{h}_\text{true}\rVert^2/\lVert\mathbf{h}_\text{true}\rVert^2in dB
Modelsn=Asn−1\mathbf{s}_n=\mathbf{A}\mathbf{s}_{n-1} + push, y[n]=c⊤sn+v[n]y[n]=\mathbf{c}^\top\mathbf{s}_n+v[n]push covariance Q\mathbf{Q}
Predictsn−=Asn−1\mathbf{s}_n^-=\mathbf{A}\mathbf{s}_{n-1}, Pn−=APn−1A⊤+Q\mathbf{P}_n^-=\mathbf{A}\mathbf{P}_{n-1}\mathbf{A}^\top+\mathbf{Q}model
Updatesn=sn−+gn(y[n]−c⊤sn−)\mathbf{s}_n=\mathbf{s}_n^-+\mathbf{g}_n(y[n]-\mathbf{c}^\top\mathbf{s}_n^-)measurement
Kalman gainPn−c/(c⊤Pn−c+σv2)\mathbf{P}_n^-\mathbf{c}/(\mathbf{c}^\top\mathbf{P}_n^-\mathbf{c}+\sigma_v^2)trust in the measurement
Ellipse±2P11\pm2\sqrt{P_{11}} along each axisholds 86.5 % of Gaussian draws

End of lesson 26.4

Where to go next.

Phasorium
LibraryEvery lesson, in order

Parts

About Phasorium
Look