Revision 722, 0.7 kB
(checked in by mido, 15 years ago)
|
astyler run over all test sources
general_suite added
cleanup of \test directory finished
|
-
Property svn:eol-style set to
native
|
Rev | Line | |
---|
[386] | 1 | #include "estim/kalman.h" |
---|
[272] | 2 | using namespace bdm; |
---|
[477] | 3 | |
---|
[272] | 4 | // estimation of AR(0) model |
---|
| 5 | int main() { |
---|
| 6 | //dimensions |
---|
[477] | 7 | int dx = 3, dy = 3, du = 1; |
---|
[272] | 8 | // matrices |
---|
[477] | 9 | mat A = eye ( dx ); |
---|
| 10 | mat B = zeros ( dx, du ); |
---|
| 11 | mat C = eye ( dx ); |
---|
| 12 | mat D = zeros ( dy, du ); |
---|
| 13 | mat Q = eye ( dx ); |
---|
| 14 | mat R = 0.1 * eye ( dy ); |
---|
[272] | 15 | //prior |
---|
[477] | 16 | mat P0 = 100 * eye ( dx ); |
---|
| 17 | vec mu0 = zeros ( dx ); |
---|
[272] | 18 | // Estimator |
---|
| 19 | KalmanCh KF; |
---|
[477] | 20 | KF.set_parameters ( A, B, C, D,/*covariances*/ Q, R ); |
---|
| 21 | KF.set_statistics ( mu0, P0 ); |
---|
[679] | 22 | KF.validate(); |
---|
[272] | 23 | // Estimation loop |
---|
[477] | 24 | for ( int i = 0; i < 100; i++ ) { |
---|
[722] | 25 | KF.bayes ( randn ( dy ), randn ( du ) ); |
---|
[272] | 26 | } |
---|
| 27 | //print results |
---|
| 28 | cout << "Posterior estimate of x is: " << endl; |
---|
[477] | 29 | cout << "mean: " << KF.posterior().mean() << endl; |
---|
| 30 | cout << "variance: " << KF.posterior().variance() << endl; |
---|
[272] | 31 | } |
---|