Understanding the Extended Kalman Filter

  • Context: Graduate 
  • Thread starter Thread starter Ultimâ
  • Start date Start date
  • Tags Tags
    Filter Kalman filter
Click For Summary

Discussion Overview

The discussion revolves around the Extended Kalman Filter (EKF), particularly focusing on the challenges of implementing it for tracking a noisy signal. Participants explore the mathematical foundations, including the calculation of Jacobians and the transition from a standard Kalman Filter to an EKF. The scope includes theoretical aspects, mathematical reasoning, and practical application in aerospace contexts.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • Charles expresses difficulty in modifying his Kalman Filter program to implement the EKF, specifically in calculating the Jacobians A_k and H_k.
  • Some participants suggest resources and references, including a book by George Born and a paper on EKF variations.
  • One participant provides a detailed mathematical derivation related to the EKF process, including the use of Taylor series for nonlinear functions.
  • Another participant questions whether an EKF is necessary for the simple system described, suggesting that a linear Kalman Filter may suffice.
  • Charles seeks clarification on calculating specific terms (f_x, h_x, and h(\hat{x}_{k+1|k}, k+1)) using example data for a noisy sinusoid.
  • There is a discussion about the definitions of state vectors and observations, with participants seeking to clarify the relationships between them.

Areas of Agreement / Disagreement

Participants do not reach a consensus on whether an EKF is necessary for the problem at hand, with some arguing for its use and others suggesting a simpler linear Kalman Filter may be adequate. The discussion remains unresolved regarding the best approach for Charles's specific case.

Contextual Notes

Participants note the complexity of the EKF and the potential for confusion in transitioning from a standard Kalman Filter. There are also references to the need for clear examples, which appear to be lacking in available resources.

Who May Find This Useful

This discussion may be useful for individuals interested in the application of Kalman Filters in aerospace, those studying statistical methods in engineering, or practitioners looking to implement EKF in their projects.

Ultimâ
Messages
32
Reaction score
0
Hi there,

I'm wasn't sure whether I should post this question in the maths section or here, but since this technique is used a lot in aerospace I thought I'd try here first.

I've grasped the idea of an ordinary Kalman Filter and created a program that tracks a noisy signal. However when it comes to modifying the program to an EKF I'm at a total loss. I've spent weeks reading up on this and searching for examples, but I'm still unable to figure how to calculate the modified equations (especially the Jacobian terms). So I have decided to ask if anyone on these forums have any expertise in this area and could possibly help me out.

Can anyone suggest how I calculate the Jacobians A_k (sometimes described as F_k) and H_k for a simple case of tracking an x-coordinate over time? I'm assuming the noise has no gain.

Thanks,
Charles
 
Astronomy news on Phys.org
Ultima, I'm going to move this thread to General Math in the hopes you get a response.

I have seen the Kalman filter used, but I certainly don't have a good enough grasp on it to explain the nuts and bolts.
 
Eh... maybe Celestial Mechanics.

Sorry for the lack of response, Ultima. It's a tricky subject.
 
Hey Ultima,

I took some graduate level courses in Statistical Orbit Determination in college unfortunately we only worked with generic Kalman filtering (and that was over 4 years ago :P ). Extended Kalman filtering was covered in another course I never had the fortune of taking. However, my former professor, George Born at the University of Colorado Boulder, co-authored a book "Statistical Orbit Determination" which covers some applications of EKF and he also wrote a paper on variations a while back:


http://www.space-flight.org/AAS_meetings/1996_winter/abstracts/96-108.html

So in short while I can't help you directly perhaps you could try contacting Prof. Born via e-mail:

http://aerospace.colorado.edu/frameset.php/facstaff/facultyHTMLfiles/born.html


He might be willing to answer your questions directly or perhaps provide you with a place to look for examples of the EKF implemented by others. Papers or perhaps other books or programs written which would be accessible online.

Hope that helps!
 
Last edited by a moderator:
I was beginning to lose hope.

Enigma, thanks for your help in finding the best place for this thread.

Goavs4, I've now put in a request with the British Library and should have the book in a week or so. I may send Prof. Born an email and see if he can suggest any good references (don't like to inconvenience people though).

From all that I've read it would appear that the step from the Kalman filter to the EKF is fairly straightforward...I think I must be just missing some fundamental issue that might be rectified through a good example, but sadly, simple examples of the EKF seem a bit like the needle in the haystack senario.

Thanks for you input Goavs4 =)
 
Consider the process:
[tex]x_{k+1} = f(x_{k},k) + w_k[/tex]
with noisy measurements:
[tex]z_k = h(x_{k},k) + v_k[/tex]
Where f and h are nonlinear functions of the state x and [tex]w_k[/tex] and [tex]v_k[/tex] are gaussian noises.
If we know an unbiased estimation [tex]\hat x_{k|k}[/tex] of the state at the instant k we can develop [tex]f(x_{k},k)[/tex] in a Taylor series around [tex]\hat x_{k|k}[/tex].
[tex]x_{k+1} = f(\hat x_{k|k},k) + f_x(\hat x_{k|k},k)e_{k|k} + \frac{1}{2}f_{xx}(\hat x_{k|k},k)e_{k|k} (x) e_{k|k} + ...[/tex]
Where:
[tex]e_{k|j} = x_k - \hat x_{k|j}[/tex]
[tex]f_x = \frac {\partial f}{\partial x^T}[/tex]
[tex]f_{xx} = \frac {\partial ^2 f}{\partial x^T \partial x^T}[/tex]
and (x) is the Kronecker matrix product.
If the errors are small, we can add the terms of second and higher orders to the noise and write:
[tex]x_{k+1} = f(\hat x_{k|k},k) + f_x(\hat x_{k|k},k)e_{k|k} + w'_k[/tex]
Before the arrival of the measurement [tex]z_{k+1}[/tex] the best estimate of [tex]x_{k+1}[/tex] is its mathematical expectation:
[tex]\hat x_{k+1|k} = E[x_{k+1}] = f(\hat x_{k|k},k)[/tex]
We can now develop [tex]h(x_k,k)[/tex] in series around the new estimate:
[tex]z_{k+1} = h(\hat x_{k+1|k},k+1) + h_x(\hat x_{k+1|k+1},k)e_{k+1|k} + \frac{1}{2}h_{xx}(\hat x_{k+1|k},k+1)e_{k+1|k} (x) e_{k+1|k} + ...[/tex]
again, supposing [tex]e_{k+1|k}[/tex] is small we can write:
[tex]z_{k+1} = h(\hat x_{k+1|k},k) + h_x(\hat x_{k+1|k},k)e_{k+1|k} + v'_{k+1}[/tex]
After the arrival of the measurement [tex]z_{k+1}[/tex] the best estimate of [tex]x_{k+1}[/tex] is:
[tex]\hat x_{k+1|k+1} = \hat x_{k+1|k} + K_{k+1}[z_{k+1} - h(\hat x_{k+1|k},k+1)][/tex]
Where
[tex]K_{k+1} = P_{k+1|k}.h_x^T[h_x.P_{k+1|k}.h_x^T + R_{k+1}]^{-1}[/tex]
[tex]P_{k+1|k} = E[e_{k+1|k} . e^T_{k+1|k} = f_x.P_{k|k}.f_x^T + Q_k[/tex]
The new error covariance matrix is:
[tex]P_{k+1|k+1} = E[e_{k+1|k+1} . e^T_{k+1|k+1} = [I - K_{k+1}.h_x].P_{k+1|k}.[I - K_{k+1}.h_x]^T + K_{k+1}.R_{k+1}.K^T_{k+1}[/tex]
Where [tex]Q_k[/tex] and [tex]R_k[/tex] are the covariances of the process and measurement noises respectively.
 
enigma said:
Eh... maybe Celestial Mechanics.

Sorry for the lack of response, Ultima. It's a tricky subject.
I would put it in Electrical Engineering or in Engineering Systems and Design.
 
Thanks SGT for that derivation. I was also amazed to learn that this forum supports Latex, which will help me express myself far better now and in the future. It really does put a smile on my face when I find I've had a reply.

Anyway, specifically I'm asking for help with calculating

[tex]f_x[/tex], [tex]h_x[/tex] and [tex]h(\hat{x}_{k+1|k}, k+1)[/tex] (from 2 posts above for any new comers).

So if we are tracking a noisy sinusoid (for example), let's say the first part of the data stream for for the observation of the input ([tex]z[/tex]) is:

0.044, 0.088, 0.143, 0.188, 0.261, 0.355, 0.352, 0.287

and the corresponding estimate of the input ([tex]\hat{x}[/tex]) is:

0.004, 0.017, 0.043, 0.077, 0.123, 0.184, 0.229, 0.244

how would the three above terms be calculated? Are the first two simply looking at the rate of change of [tex]z[/tex] and [tex]\hat{x}[/tex] and the last term ([tex]h(\hat{x}_{k+1|k}, k+1)[/tex]) simply equal to [tex]\hat{x}[/tex] for this example?
 
Last edited:
  • #10
Ultimâ said:
Thanks SGT for that derivation. I was also amazed to learn that this forum supports Latex, which will help me express myself far better now and in the future. It really does put a smile on my face when I find I've had a reply.

Anyway, specifically I'm asking for help with calculating

[tex]f_x[/tex], [tex]h_x[/tex] and [tex]h(\hat{x}_{k+1|k}, k+1)[/tex].

So if we are tracking a noisy sinusoid (for example), let's say the first part of the data stream for for the observation of the input ([tex]z[/tex]) is:

0.044, 0.088, 0.143, 0.188, 0.261, 0.355, 0.352, 0.287

and the corresponding estimate of the input ([tex]\hat{x}[/tex]) is:

0.004, 0.017, 0.043, 0.077, 0.123, 0.184, 0.229, 0.244

how would the three above terms be calculated? Are the first two simply looking at the rate of change of [tex]z[/tex] and [tex]\hat{x}[/tex] and the last term ([tex]h(\hat{x}_{k+1|k}, k+1)[/tex]) simply equal to [tex]\hat{x}[/tex] for this example?

Could you elaborate a little more? What is your state vector [tex]x[/tex]? Are its components position and velocity? And what are your observations [tex]z[/tex]? Is [tex]z[/tex] the measurement of the position?
What are the functions [tex]f(x_k,k)[/tex] and [tex]h(x_k,k)[/tex] ?
 
Last edited by a moderator:
  • #11
Right, we're just dealing with an x-position with respect to k, [tex]x[/tex] and [tex]z[/tex] can be treated as scalers. So for the first k, the observation is 0.004, [tex]z=h(x_k,k)+v_k=Hx_k[/tex]+ [tex]v_k[/tex], in this case the observation is of the state directly, so H is unity) and the state is [tex]x_{k+1}+w_k=f(x_k,k)=Ax_k+w_k[/tex]
 
Last edited:
  • #12
For such a simple system you don't need an EKF. A linear Kalman Filter will do. Your state is simply:
[tex]\vec x = \left [<br /> \begin{array}{cc}<br /> x \\<br /> \dot x <br /> \end{array}<br /> \right ][/tex]
Your state equation is linear:
[tex]\vec x_{k+1} = A.\vec x_k + w_k[/tex]
where
[tex]A = \left [<br /> \begin{array}{cc}<br /> 1 & T \\<br /> 0 & 1 <br /> \end{array}<br /> \right ][/tex]
and T is the time interval between observations.
For the initial position [tex]x_0[/tex] you take the first observation [tex]z_0[/tex] and for the initial velocity you take the difference of the first two measurements divided by T.
[tex]\vec x_0 = \left [<br /> \begin{array}{cc}<br /> 0.044 \\<br /> \frac {0.044}{T} <br /> \end{array}<br /> \right ][/tex]
For the initial value of the error covariance matrix you can use :
[tex]P_{0|0} = \left [<br /> \begin{array}{cc}<br /> 100\sigma_x^2 & 0 \\<br /> 0 & 100\sigma_v^2 <br /> \end{array}<br /> \right ][/tex]
The matrix R is simply the scalar [tex]\sigma_z^2[/tex]
 
Last edited by a moderator:
  • #13
Although, I'll probably find this bit of information (working with vectors in KF) beneficial in the long term, in my first post I mention that I've implemented a scaler version of the Kalman Filter that works fine (In my model I assume [tex]x_0[/tex]=0 and [tex]P_0[/tex]=1). The idea was to amend this so it acted as an extended kalman filter. I realize that the KF is better for such a simple system, but my aim is to understand the EKF. When I tried to apply the EKF, I found I was unsure how to calculate the three variables mentioned in post #9.
 
  • #14
You cannot use an EKF with a linear system. And a scalar linear Kalman filter is inefficient. Since the KF can provide you with velocity information, why not use it? The abandon of this information will provide you with a smoothed estimation. You said your data belonged to a sinusoid. If you don't use the velocity information you will end with the mean value of the sinusoid: zero.
 
  • #15
My KF model comes from the example in the following paper
http://www.cs.unc.edu/~welch/media/pdf/kalman_intro.pdf

I then changed the input signal from a constant voltage to a sinewave. The programmed filter tracks it reasonably well provided R and Q are choosen wisely.

Velocity isn't used in the example so I didn't incorporate it in my initial program model.

My understanding of the EKF is that, yes it is designed to handle non-linear systems, but this is through linearising the model at its current position, which suggests that it can be applied to linear models, but will not be as accurate as the normal kf.

So we are effectively tracking the position, with only the observation of a single x-coordinate available to us. I'd expect the ekf should produce better results for such a situation...
 
Last edited:
  • #16
The example from the paper deals with the estimation of a constant, so there is no velocity involved. If you want to estimate the position of a mobile you must either know its velocity or to estimate it through the filter.
You cannot use an EKF with a linear system, because the functions [tex]f[/tex] and [tex]h[/tex] are linear functions of the state [tex]x[/tex], so their derivatives [tex]f_x[/tex] and [tex]h_x[/tex] are simply constants.
 
Last edited by a moderator:
  • #17
This makes sense, [tex]f_x[/tex] and [tex]h_x[/tex] seemed to become zero when I tried to calculate them and may be the fundamental reason why I am having difficulty understanding the EKF. So what would be the simplest non-linear model to apply an EKF too?
 
  • #18
Ultimâ said:
This makes sense, [tex]f_x[/tex] and [tex]h_x[/tex] seemed to become zero when I tried to calculate them and may be the fundamental reason why I am having difficulty understanding the EKF. So what would be the simplest non-linear model to apply an EKF too?
Suppose you have a stationary point in a plane, with coordinates [tex]x_0[/tex] and [tex]y_0[/tex]. You measure the distance and the azimuth from the origin to the point:
[tex]d = \sqrt{x_0^2 + y_0^2} + \nu_d[/tex]
[tex]az = tan^{-1}\frac{y}{x} + \nu_{az}[/tex]
Now your [tex]h[/tex] is a nonlinear function of the state and you can calculate [tex]h_x[/tex].
The function [tex]f[/tex] is still linear, but if one of the two functions is nonlinear you must use an EKF.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 7 ·
Replies
7
Views
23K
Replies
4
Views
7K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 8 ·
Replies
8
Views
7K