Show
Ignore:
Timestamp:
08/05/09 14:40:03 (15 years ago)
Author:
mido
Message:

panove, vite, jak jsem peclivej na upravu kodu.. snad se vam bude libit:) konfigurace je v souboru /system/astylerc

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/tests/arx_test.cpp

    r386 r477  
    11/*! 
    2 \file  
     2\file 
    33\brief Test of basic elements of the ARX class 
    44 
     
    1717        // Setup model 
    1818        vec th ( "0.8 -0.3 0.4 0.01" ); 
    19         int ord=th.length(); //auxiliary variable 
    20         double sqr=0.1; 
     19        int ord = th.length(); //auxiliary variable 
     20        double sqr = 0.1; 
    2121 
    2222        //Test constructor 
    23         mat V0 = 0.00001*eye ( ord+1 ); V0 ( 0.0 ) = 1; // 
    24         double nu0 = ord+5.0; 
     23        mat V0 = 0.00001 * eye ( ord + 1 ); 
     24        V0 ( 0.0 ) = 1; // 
     25        double nu0 = ord + 5.0; 
    2526 
    2627        ARX Ar; 
    27         Ar.set_statistics(1, V0, nu0 );                 // Estimator 
     28        Ar.set_statistics ( 1, V0, nu0 );               // Estimator 
    2829        const epdf& f_thr = Ar.posterior();          // refrence to posterior of the estimator 
    2930 
     
    3132        int ndat = 100;                 // number of data records 
    3233        vec Yt ( ndat );                // Store generated data 
    33         Yt.set_subvector ( 0,randn ( ord ) ); //initial values 
     34        Yt.set_subvector ( 0, randn ( ord ) ); //initial values 
    3435        vec rgr ( ord );                // regressor 
    35         vec Psi ( ord+1 );              // extended regressor 
     36        vec Psi ( ord + 1 );            // extended regressor 
    3637 
    3738        //print moments of the prior distribution 
    38         cout << "prior mean: " << f_thr.mean() <<endl; 
    39         cout << "prior variance: " << f_thr.variance() <<endl; 
     39        cout << "prior mean: " << f_thr.mean() << endl; 
     40        cout << "prior variance: " << f_thr.variance() << endl; 
    4041 
    4142        // cycle over time: 
    42         for ( int t=ord; t<ndat; t++ ) { 
     43        for ( int t = ord; t < ndat; t++ ) { 
    4344                //Generate regressor 
    44                 for ( int j=0;j< ( ord );j++ ) {rgr ( j ) =Yt ( t-j-1 );} 
     45                for ( int j = 0; j < ( ord ); j++ ) { 
     46                        rgr ( j ) = Yt ( t - j - 1 ); 
     47                } 
    4548                //model 
    46                 Yt ( t ) = th*rgr + sqr * NorRNG(); 
     49                Yt ( t ) = th * rgr + sqr * NorRNG(); 
    4750 
    4851                Psi = concat ( Yt ( t ), rgr ); // Inefficient! Used for compatibility with Matlab! 
     
    5356                // Test similarity of likelihoods from the Bayes rule and the predictor 
    5457                cout << "BR log-lik: " << Ar._ll(); 
    55                 cout <<" , predictor ll: " <<  Pr->evallogcond ( vec_1 ( Yt ( t ) ),rgr )  <<endl; 
     58                cout << " , predictor ll: " <<  Pr->evallogcond ( vec_1 ( Yt ( t ) ), rgr )  << endl; 
    5659                delete Pr; 
    5760        } 
    5861        //print posterior moments 
    59         cout << "posterior mean: " << f_thr.mean() <<endl; 
    60         cout << "posterior variance: " << f_thr.variance() <<endl; 
     62        cout << "posterior mean: " << f_thr.mean() << endl; 
     63        cout << "posterior variance: " << f_thr.variance() << endl; 
    6164 
    6265        // Test brute-froce structure estimation 
    63          
    64         cout << "Structure estimation: " <<endl; 
    65         cout <<Ar.structure_est ( egiw ( 1,V0,nu0 ) ) <<endl; 
     66 
     67        cout << "Structure estimation: " << endl; 
     68        cout << Ar.structure_est ( egiw ( 1, V0, nu0 ) ) << endl; 
    6669}