Reputation: 3405
I have a simple problem. I am tracking an object and getting its position in non-uniform time intervals. Velocity and accelration of object are not constant.
data_=[time x,y,z]
To design a kalman filter, I need to define
z=[x;y;z] % observation
% Estimation vector
xt=[xt;yt;zt;x't;y't;z't] % ' first derivative
P=Covariance matrix of estimation vector
R=Covariance matrix of measurement
Q= covariance of noise
Question1: What is difference between these two R & P If measurment accuracy is 1mm what would be P? Question2: What is benefit of using this Kalman filter in post processing. It it to get smoth trajectory if yes why we need it.
Hope I will get enough information from you people.
Upvotes: 5
Views: 983
Reputation: 4525
Kalman filter can be described first by graphical model that shows dependencies, independences, what's hidden and what's observed, how things evolve; also by probability formulas and only then by explicitly writing these probabilities through matrices that represents noise, linear models, etc. Understanding probabilities is a first unavoidable step before writing them as matrix models (a typical mistake is jumping to the matrices and linear algebra without understanding underlying probabilistic framework).
Below W means world state variable (hidden) and X represent measurements; lower index t is a time step.
Question 1:
You have two models that Kalman filter is based on:
a. Data model P(Xt|Wt) = probability of measurement given a hidden state of the world; this is simply a model of the noise in data (represented by R) which also linearly transforms W to get X (using some other matrix); NOTE that it depends only on current step Wt, i.e. no history involved.
b. Temporal transition model P(Wt|Wt-1) which shows how your system evolves (e.g. moves, accelerates); just like the previous model it also has some uncertainty (not noise but similar) represented by P and also some linear transition matrix (to transform states in time);
c. Q? 'covariance of noise' is a strange term in your question since it doen't say where this noise comes from. Often in descriptions Q is what you referred by P, so you probably just mistaken P for Q or vice versa.
Question 2: the goal of Kalman filter is to give a statistically optimal estimate of the hidden world state at time t given measurements at time t as well as the history of measurements. Since the history is incorporate one step at a time (Markov property) you "measurement incorporation" step combines a current measurement with its estimation so that the resulting uncertainty is smaller than in each of these pieces of information.
In layman's terms a Kalman filter takes a weighted average of your data and data prediction where the weights are reliabilities (inversely proportional to the variances). In statistical terms, a Kalman filter is a Markov model that assumes dependence on the previous step only and uses posterior probability of state at t-1 to evaluate the prior at time t (prediction step) and then combine this prior with data probability in Bayesian framework (measurement incorporation step). Read formuli below like this:
prediction: current state guess = transition_model * prev. state guess
P(Wt | Xt1..t-1) = Integral[ P(Wt|Wt-1) * P(Wt-1 | X1..t-1) dWt-1]
measurement: best estimate = data_noise_model * current state guess
P(Wt | Xt1..t) = P(Xt | Wt) P(Wt | Xt1..t-1) /P(Xt1..t)
Note a tiny difference in LHS (a top formula has t-1 and the bottom one has t stressing that a current measurement is taken into account). Note the similarity of left sides, this is a key for a Kalman filter update: previous posterior become a prior. You learn something and then use it as your assumptions to learn/estimate more.
Upvotes: 2
Reputation: 22245
Question 1
R is the covariance matrix of the measurement. It has nothing to do with your model and your estimations.
P is the covariance matrix of the errors in your estimations. It is totally realted to your model and the way you estimate the state. P has nothing to do with your accuracy on measurements. You have to compute it every iteration with update equations.
Question 4
Kalman's goal is filtering noisy measurements of the state you want to track, so you can get a result more similar to the real state without noise (noise is uncertainty in your measurements).
Upvotes: 4