0
$\begingroup$

I read lots of things about Kalman filtering, but in order to fully understand it, I would probably need to see it working on some data.

Would you have a minimal example (Python code or any other language) showing what it does on some real data $x[n]$, where $n$ is the time?

$\endgroup$

3 Answers 3

1
$\begingroup$

I created a simple example with Scilab/XCOS. It is a simulation of lowpass filter with noise. It is observed by a kalman filter. You can also insert some uncertainties in the system model. With XCOS you can simulate the system. The results will be plotted automatically. Here is the Downloadlink.

Little help with scilab: Go to the directory with standard unix command

cd /home/workingdir/Kalman_Example

There you should execute getd() to load all functions (.sci-files) in the directory. Then you can execute the modeling.sce file, which is just an initializing script:

exec('modelling.sce')

Then typexcos simulation_kalm1.zcos into the console. A graphic window will open. Press the play button and the simulation will start.

$\endgroup$
4
  • $\begingroup$ With the console you can go to the directory with standard unix command cd /home/workingdir/ $\endgroup$
    – peng
    Jan 10, 2016 at 21:25
  • $\begingroup$ What does exec(modeling.sce) do? It should load initial variables to the workspace. The workspace is shown in the right side of the console window. $\endgroup$
    – peng
    Jan 10, 2016 at 22:57
  • $\begingroup$ 1) Go to the dir. [with ls you see all necessary files?] 2) getd() to load fuctions 3) exec(modeling) to execute the script - the results appear at the console and in the workspace? 4) xcos simulation_kalm1.zcos opens the XCOS simulation 5) Press Play-Button starts the simulation and the graphs appear in a plot. Which step makes problems? $\endgroup$
    – peng
    Jan 10, 2016 at 23:18
  • $\begingroup$ Now you can a) vary the noise covariance (or the assumtion about it in the kalman code) and you can add some uncertainties in the plant transfer function or in the state space model. I hope, that helps to understand, how it works. $\endgroup$
    – peng
    Jan 11, 2016 at 10:18
1
$\begingroup$

If R is OK to use, then try the various answers I've made here.

$\endgroup$
1
$\begingroup$

Kalman and Bayesian Filters in Python is interactive book about Kalman filter. It contain a lot of code on Pyhton from simple snippets to whole classes and modules. For simplest example see chapter about one dimentional Kalman filter.

but in order to fully understand it, I would probably need to see it working on some data

P.S. Also in my opinion there is not enought to see Kalman filter example to understand it. You also need understand a problem domain (process model).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.