.
and
and system and measurement noise
and
.Now, instantiate an object of your model class:
MyParticleFilterModel model;
and a prior distribution over the state of the system:
indii::ml::aux::vector mu(5); indii::ml::aux::symmetric_matrix sigma(5); mu.clear(); mu(0) = -1.0; mu(1) = 1.0; mu(2) = 0.8; mu(3) = 0.1; mu(4) = 5e-3; sigma.clear(); sigma(0,0) = 1.0; sigma(1,1) = 1.0; sigma(2,2) = 0.01; sigma(3,3) = 1e-6; sigma(4,4) = 1e-6; indii::ml::aux::GaussianPdf tmp(mu, sigma); indii::ml::aux::DiracMixturePdf x0(tmp, 500);
Pass both of these to the constructor of your chosen method to instantiate it:
ParticleFilter filter(&model, x0);
Apply the method by using its step functions to advance it forwards or backwards through time, passing in the relevant measurement at each step. After each step, retrieve the estimated system state.
unsigned int T = 100; unsigned int t; double y[T] = { ... }; // measurements, perhaps read in from a file for (t = 1; t <= T; t++) { filter.filter(t, y[t]); std::cout << t << '='; std::cout << filter.getFilteredState().getExpectation() << std::endl; }
Smoothers have a similar usage idiom. First filter the data, then initialise a smoother, such as ParticleSmoother, with the last state of the filter, and use the smoother's stepping function to proceed backward through time.
See the test suite for more elaborate example code.
| enum Flags |
Optimisation flags.
These may be ORed and passed to the smooth() methods to trigger optimisations relevant in specific circumstances.
1.5.3