| 
            Revision 477, 0.7 kB
            (checked in by mido, 16 years ago)
           | 
        
        
          | 
               
panove, vite, jak jsem peclivej na upravu kodu.. snad se vam bude libit:) konfigurace je v souboru /system/astylerc  
 
           | 
        
        
          
            
              - 
                  Property svn:eol-style set to
                    
native
               
             
           | 
        
      
      
    | Line |   | 
|---|
| 1 | #include "estim/kalman.h" | 
|---|
| 2 | using namespace bdm; | 
|---|
| 3 |  | 
|---|
| 4 | // estimation of AR(0) model | 
|---|
| 5 | int main() { | 
|---|
| 6 |         //dimensions | 
|---|
| 7 |         int dx = 3, dy = 3, du = 1; | 
|---|
| 8 |         // matrices | 
|---|
| 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 ); | 
|---|
| 15 |         //prior | 
|---|
| 16 |         mat P0 = 100 * eye ( dx ); | 
|---|
| 17 |         vec mu0 = zeros ( dx ); | 
|---|
| 18 |         // Estimator | 
|---|
| 19 |         KalmanCh KF; | 
|---|
| 20 |         KF.set_parameters ( A, B, C, D,/*covariances*/ Q, R ); | 
|---|
| 21 |         KF.set_statistics ( mu0, P0 ); | 
|---|
| 22 |         // Estimation loop | 
|---|
| 23 |         for ( int i = 0; i < 100; i++ ) { | 
|---|
| 24 |                 KF.bayes ( randn ( dx + du ) ); | 
|---|
| 25 |         } | 
|---|
| 26 |         //print results | 
|---|
| 27 |         cout << "Posterior estimate of x is: "  << endl; | 
|---|
| 28 |         cout << "mean: " << KF.posterior().mean() << endl; | 
|---|
| 29 |         cout << "variance: " << KF.posterior().variance() << endl; | 
|---|
| 30 | } | 
|---|