|
Revision 8, 1.3 kB
(checked in by smidl, 18 years ago)
|
|
Kalmany funkci, PF nefunkci
|
-
Property svn:eol-style set to
native
|
| Rev | Line | |
|---|
| [8] | 1 | /*! |
|---|
| 2 | \file |
|---|
| 3 | \brief Bayesian Filtering using stochastic sampling (Particle Filters) |
|---|
| 4 | \author Vaclav Smidl. |
|---|
| 5 | |
|---|
| 6 | ----------------------------------- |
|---|
| 7 | BDM++ - C++ library for Bayesian Decision Making under Uncertainty |
|---|
| 8 | |
|---|
| 9 | Using IT++ for numerical operations |
|---|
| 10 | ----------------------------------- |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | #ifndef PF_H |
|---|
| 14 | #define PF_H |
|---|
| 15 | |
|---|
| 16 | #include <itpp/itbase.h> |
|---|
| 17 | #include "libBM.h" |
|---|
| 18 | #include "libDC.h" |
|---|
| 19 | |
|---|
| 20 | using namespace itpp; |
|---|
| 21 | |
|---|
| 22 | enum RESAMPLING_METHOD { MULTINOMIAL = 0, DETERMINISTIC = 1, RESIDUAL = 2, SYSTEMATIC = 3 }; |
|---|
| 23 | |
|---|
| 24 | /*! |
|---|
| 25 | * \brief A Particle Filter prototype |
|---|
| 26 | |
|---|
| 27 | Bayesian Filtering equations hold. |
|---|
| 28 | */ |
|---|
| 29 | class PF : public BM { |
|---|
| 30 | protected: |
|---|
| 31 | int n; //number of particles |
|---|
| 32 | vec w; //particle weights |
|---|
| 33 | |
|---|
| 34 | public: |
|---|
| 35 | //! Returns indexes of particles that should be resampled |
|---|
| 36 | ivec resample(RESAMPLING_METHOD method = SYSTEMATIC); |
|---|
| 37 | //TODO get them on the web |
|---|
| 38 | }; |
|---|
| 39 | |
|---|
| 40 | /*! |
|---|
| 41 | * \brief Trivial particle filter with proposal density that is not conditioned on the data. |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | */ |
|---|
| 45 | |
|---|
| 46 | class TrivialPF : public PF { |
|---|
| 47 | Array<vec> ptcls; |
|---|
| 48 | |
|---|
| 49 | bool is_proposal; |
|---|
| 50 | mpdf *prop; |
|---|
| 51 | mpdf *par; |
|---|
| 52 | mpdf *obs; |
|---|
| 53 | |
|---|
| 54 | public: |
|---|
| 55 | TrivialPF(mpdf &par, mpdf &obs, mpdf &prop, int n0); |
|---|
| 56 | TrivialPF(mpdf &par, mpdf &obs, int n0); |
|---|
| 57 | void bayes(const vec &dt, bool evalll); |
|---|
| 58 | }; |
|---|
| 59 | |
|---|
| 60 | class MPF : public TrivialPF { |
|---|
| 61 | Array<BM> Bms; |
|---|
| 62 | public: |
|---|
| 63 | MPF(BM &B, mpdf &prop, mpdf &obs, mpdf &par); |
|---|
| 64 | void bayes(vec &dt); |
|---|
| 65 | }; |
|---|
| 66 | |
|---|
| 67 | #endif // KF_H |
|---|
| 68 | |
|---|