Kalman 102 : 1D tracking

I have developed some interest in Kalman tracking.

Found this writeup 

http://ourworld.compuserve.com/homepages/PDJoseph/kalman.htm

written by PETER D. JOSEPH who sent me further chapters of his lectures.

I Decided to implement 1D Kalman tracking for a set of measurements y(t).

INPUT : list of single-value measurements as function of time, e.g. beam line X displacement vs. time.

INTERNAL STATE VECTOR: {x, dx/dt} and cov-matrix

OUTPUT:  estimators x(t)  dx/dt(t) and errors.

PARAMETERS: starting point & assumed error of measurements  

 

Algo has been tested on data distributed with Gauss round:  

     float yTrue=y0+j/30;

    if(j>500) yTrue=y0-j/30;

    float t1=j+1; // new time

    float y1=rnd.Gaus(yTrue,5); // new value

  

I was interested how Kalman will handle this jump in values at T=500 for two assumed sigma of the measurement (although the same sigma was used to throw the 'measurements'.

On the right plot you see residua for T=[200,480] - when measurements smoothly changed with time and Kalman was already stable.

The root code is attached at the bottom

 

Fig 1, assumed sigma of measurement of 10

 

Fig 2, assumed sigma of measurement of 30