Changeset 1077
- Timestamp:
- 06/10/10 21:40:09 (15 years ago)
- Location:
- library/bdm
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.h
r1068 r1077 1279 1279 //! \var log_level_enums logbounds 1280 1280 //! log lower and upper bounds of estimates 1281 1281 1282 LOG_LEVEL(BM,logfull,logevidence,logbounds); 1282 1283 … … 1416 1417 1417 1418 //!@} 1418 //! \brief Read names of random variables from setting 1419 /*! 1420 reading structure: 1419 1420 /*! Create object from the following structure 1421 1421 \TODO check if not remove... rv... 1422 1422 1423 \code 1423 yrv = RV(); // names of modelled data 1424 rvc = RV(); // names of data in condition 1425 rv = RV(); // names of parameters 1426 log_level = "logmean"; // identifiers of levels of detail to store to loggers 1424 class = 'BM'; 1425 --- optional fields --- 1426 log_level = "..."; % identifiers of levels of detail to store to loggers 1427 yrv = RV({'names',...},[sizes,...],[times,...]); % names of modelled data 1428 rvc = RV({'names',...},[sizes,...],[times,...]); % names of data in condition 1429 rv = RV({'names',...},[sizes,...],[times,...]); % names of parameters 1430 --- inherited fields --- 1431 bdm::root::from_setting 1427 1432 \endcode 1428 1433 */ -
library/bdm/estim/arx.h
r1064 r1077 27 27 Regression of the following kind: 28 28 \f[ 29 y_t = \theta_1 \psi_1 + \theta_2 + \psi_2 +\ldots + \theta_n \psi_n + r e_t29 y_t = heta_1 \psi_1 + heta_2 + \psi_2 +\ldots + heta_n \psi_n + r e_t 30 30 \f] 31 where unknown parameters \c rv are \f$[ \theta r]\f$, regression vector \f$\psi=\psi(y_{1:t},u_{1:t})\f$ is a known function of past outputs and exogeneous variables \f$u_t\f$. Distrubances \f$e_t\f$ are supposed to be normally distributed:31 where unknown parameters \c rv are \f$[ heta r]\f$, regression vector \f$\psi=\psi(y_{1:t},u_{1:t})\f$ is a known function of past outputs and exogeneous variables \f$u_t\f$. Distrubances \f$e_t\f$ are supposed to be normally distributed: 32 32 \f[ 33 33 e_t \sim \mathcal{N}(0,1). … … 39 39 \include arx_simple.cpp 40 40 41 \todo sort out constant terms - bayes should accept vec without additional 1s41 odo sort out constant terms - bayes should accept vec without additional 1s 42 42 */ 43 43 class ARX: public BMEF { … … 132 132 //!@} 133 133 134 /*! UI for ARX estimator134 /*! Create object from the following structure 135 135 136 136 \code 137 137 class = 'ARX'; 138 yrv = RV({names_of_dt} ) // description of output variables 139 rgr = RV({names_of_regressors}, [-1,-2]} // description of regressor variables 140 constant = 1; // 0/1 switch if the constant term is modelled or not 141 142 --- optional --- 143 prior = {class='egiw',...}; // Prior density, when given default is used instead 144 alternative = {class='egiw',...}; // Alternative density in stabilized estimation, when not given prior is used 145 146 frg = 1.0; // forgetting, default frg=1.0 147 148 rv = RV({names_of_parameters}} // description of parametetr names 149 // default: [""] 138 rgr = RV({'names',...},[sizes,...],[times,...]); % description of regressor variables 139 --- optional fields --- 140 prior = configuration of bdm::egiw; % any offspring of eqiw for prior density, bdm::egiw::from_setting 141 alternative = configuration of bdm::egiw; % any offspring of eqiw for alternative density in stabilized estimation of prior density 142 constant = []; % 0/1 switch if the constant term is modelled or not 143 --- inherited fields --- 144 bdm::BMEF::from_setting 145 \endcode 146 If the optional fields are not given, they will be filled as follows: 147 \code 148 prior = posterior; % when prior is not given the posterior is used (TODO it is unclear) 149 alternative = prior; % when alternative is not given the prior is used 150 constant = 1; % constant term is modelled on default 150 151 \endcode 151 152 */ … … 208 209 SHAREDPTR ( ARX ); 209 210 210 /*! ARX model conditined by knowledge of the forgetting factor211 \f[ f( \theta| d_1 \ldots d_t , \phi_t) \f]211 /*! \brief ARX model conditined by knowledge of the forgetting factor 212 \f[ f( heta| d_1 \ldots d_t , \phi_t) \f] 212 213 213 214 The symbol \f$ \phi \f$ is assumed to be the last of the conditioning variables. -
library/bdm/estim/kalman.h
r1064 r1077 137 137 return est; 138 138 } 139 //! load basic elements of Kalman from structure 140 /*! \code 141 class = 'KalmanFull'; 142 A = []; // Matrix A 143 B = []; // Matrix B 144 C = []; // Matrix C 145 D = []; // Matrix D 146 Q = []; // Matrix Q 147 R = []; // Matrix R 148 prior = struct('class','epdf_offspring'); // Prior density - will be converted to gaussian 149 yrv = RV('some_names'); // Description of required observations 150 rvc = RV('some_names'); // Description of required inputs 151 \endcode 152 153 */ 139 140 /*! Create object from the following structure 141 142 \code 143 class = 'KalmanFull'; 144 prior = configuration of bdm::epdf; % prior density represented by any offspring of epdf, bdm::epdf::from_setting - it will be converted to gaussian 145 --- inherited fields --- 146 bdm::StateSpace<sq_T>::from_setting 147 bdm::BM::from_setting 148 \endcode 149 */ 154 150 void from_setting ( const Setting &set ) { 155 151 StateSpace<sq_T>::from_setting ( set ); … … 242 238 void bayes ( const vec &yt, const vec &cond = empty_vec ); 243 239 240 /*! Create object from the following structure 241 242 \code 243 class = 'KalmanCh'; 244 --- inherited fields --- 245 bdm::Kalman<chmat>::from_setting 246 \endcode 247 */ 244 248 void from_setting ( const Setting &set ) { 245 249 Kalman<chmat>::from_setting ( set ); 246 validate();247 } 250 } 251 248 252 void validate() { 249 253 Kalman<chmat>::validate(); … … 283 287 return est._R().to_mat(); 284 288 } 289 290 /*! Create object from the following structure 291 292 \code 293 class = 'EKFfull'; 294 295 OM = configuration of bdm::diffbifn; % any offspring of diffbifn, bdm::diffbifn::from_setting 296 IM = configuration of bdm::diffbifn; % any offspring of diffbifn, bdm::diffbifn::from_setting 297 dQ = [...]; % vector containing diagonal of Q 298 dR = [...]; % vector containing diagonal of R 299 --- optional fields --- 300 mu0 = [...]; % vector of statistics mu0 301 dP0 = [...]; % vector containing diagonal of P0 302 -- or -- 303 P0 = [...]; % full matrix P0 304 --- inherited fields --- 305 bdm::BM::from_setting 306 \endcode 307 If the optional fields are not given, they will be filled as follows: 308 \code 309 mu0 = [0,0,0,....]; % empty statistics 310 P0 = eye( dim ); 311 \endcode 312 */ 285 313 void from_setting ( const Setting &set ) { 286 314 BM::from_setting ( set ); … … 365 393 //! Here dt = [yt;ut] of appropriate dimensions 366 394 void bayes ( const vec &yt, const vec &cond = empty_vec ); 367 395 396 /*! Create object from the following structure 397 398 \code 399 class = 'EKFCh'; 400 OM = configuration of bdm::diffbifn; % any offspring of diffbifn, bdm::diffbifn::from_setting 401 IM = configuration of bdm::diffbifn; % any offspring of diffbifn, bdm::diffbifn::from_setting 402 dQ = [...]; % vector containing diagonal of Q 403 dR = [...]; % vector containing diagonal of R 404 --- optional fields --- 405 mu0 = [...]; % vector of statistics mu0 406 dP0 = [...]; % vector containing diagonal of P0 407 -- or -- 408 P0 = [...]; % full matrix P0 409 --- inherited fields --- 410 bdm::BM::from_setting 411 \endcode 412 If the optional fields are not given, they will be filled as follows: 413 \code 414 mu0 = [0,0,0,....]; % empty statistics 415 P0 = eye( dim ); 416 \endcode 417 */ 368 418 void from_setting ( const Setting &set ); 369 419 … … 481 531 State-Space representation of multivariate autoregressive model. 482 532 The original model: 483 \f[ y_t = \theta [\ldots y_{t-k}, \ldots u_{t-l}, \ldots z_{t-m}]' + \Sigma^{-1/2} e_t \f]533 \f[ y_t = heta [\ldots y_{t-k}, \ldots u_{t-l}, \ldots z_{t-m}]' + \Sigma^{-1/2} e_t \f] 484 534 where \f$ k,l,m \f$ are maximum delayes of corresponding variables in the regressor. 485 535 -
library/bdm/estim/mixtures.cpp
r1064 r1077 39 39 //Coms ( i )->flatten ( SharpCom.get(), 1.0/Coms.length() ); 40 40 } 41 MixEF_options old_opt =options;42 MixEF_options ini_opt=options;41 Options old_opt =options; 42 Options ini_opt=options; 43 43 ini_opt.method = EM; 44 44 ini_opt.max_niter= 1; -
library/bdm/estim/mixtures.h
r1066 r1077 31 31 mixture models of the following kind: 32 32 \f[ 33 f(y_t|\psi_t, \Theta) = \sum_{i=1}^{n} w_i f(y_t|\psi_t, \theta_i)33 f(y_t|\psi_t, heta) = \sum_{i=1}^{n} w_i f(y_t|\psi_t, heta_i) 34 34 \f] 35 where \f$\psi\f$ is a known function of past outputs, \f$w=[w_1,\ldots,w_n]\f$ are component weights, and component parameters \f$ \theta_i\f$ are assumed to be mutually independent. \f$\Theta\f$ is an aggregation af all component parameters and weights, i.e. \f$\Theta = [\theta_1,\ldots,\theta_n,w]\f$.35 where \f$\psi\f$ is a known function of past outputs, \f$w=[w_1,\ldots,w_n]\f$ are component weights, and component parameters \f$ heta_i\f$ are assumed to be mutually independent. \f$ heta\f$ is an aggregation af all component parameters and weights, i.e. \f$ heta = [ heta_1,\ldots, heta_n,w]\f$. 36 36 37 37 The characteristic feature of this model is that if the exact values of the latent variable were known, estimation of the parameters can be handled by a single model. For example, for the case of mixture models, posterior density for each component parameters would be a BayesianModel from Exponential Family. … … 50 50 class MixEF: public BMEF { 51 51 protected: 52 //! Models for Components of \f$ \theta_i\f$52 //! Models for Components of \f$ heta_i\f$ 53 53 Array<BMEF*> Coms; 54 54 //! Statistics for weights … … 72 72 ////!indices of component rvc in common rvc 73 73 74 class MixEF_options: public root {74 class Options: public root { 75 75 public: 76 76 //! Flag for a method that is used in the inference … … 80 80 int max_niter; 81 81 82 MixEF_options():method(QB),max_niter(10) {};83 84 //! Settings for MixEF85 /*! 82 Options():method(QB),max_niter(10) {}; 83 84 /*! Create object from the following structure 85 86 86 \code 87 method = "EM"; % or QB (default) 88 max_iter = 10; % maximum number of iterations 87 --- optional fields --- 88 method = '...'; % 'EM' or 'QB', methods of computing bayes 89 max_iter = []; % maximum number of iterations in bayes_batch 90 --- inherited fields --- 91 bdm::root::from_setting 92 \endcode 93 If the optional fields are not given, they will be filled as follows: 94 \code 95 max_niter = 10; 96 method = 'QB'; 89 97 \endcode 90 98 */ … … 98 106 UI::get(max_niter,set,"max_niter",UI::optional); 99 107 }; 108 100 109 void to_setting(Setting &set)const { 101 110 string meth=(method==EM ? "EM" : "QB"); … … 105 114 }; 106 115 107 MixEF_options options;116 Options options; 108 117 public: 109 118 //! Full constructor … … 170 179 UI::save (options, set, "options"); 171 180 } 172 /*! \brief reads data from setting 181 182 /*! Create object from the following structure 183 173 184 \code 174 Coms = {struct('class',"BMEF..."),...}; % Components - Bayesian models (BM) 175 weights = [0.2, 0.3,...]; % weights 176 options.method = "EM" or "QB"; % methods of computing bayes 177 options.max_iter = 10; % maximum number of iterations in bayes_batch 185 class = 'MixEF'; 186 Coms = { list of bdm::BMEF }; % list of components containing any offsprings of Bayesian models BMEF, bdm::BMEF::from_setting 187 weights = [...]; % vector containing weights of components 188 --- optional fields --- 189 options = configuration of bdm::MixEF::Options; % see MixEF::Options, bdm::MixEF::Options::from_setting 190 --- inherited fields --- 191 bdm::BMEF::from_setting 178 192 \endcode 179 193 */ … … 187 201 UIREGISTER ( MixEF ); 188 202 203 //! \brief TODO DOCUMENTATION IS MISSING HERE 189 204 class ARXprod: public ProdBMBase { 190 205 Array<shared_ptr<ARX> > arxs; -
library/bdm/estim/particles.h
r1068 r1077 67 67 } 68 68 } 69 70 71 /*! Create object from the following structure 72 73 \code 74 class = "MarginalizedParticleBase"; 75 bm = configuration of bdm::BM; % any offspring of BM, bdm::BM::from_setting 76 --- inherited fields --- 77 bdm::BM::from_setting 78 \endcode 79 */ 69 80 void from_setting(const Setting &set) { 70 81 BM::from_setting ( set ); … … 78 89 }; 79 90 91 //! \brief Internal class used in PF (surely?) 80 92 class MarginalizedParticle : public MarginalizedParticleBase { 81 93 protected: … … 110 122 } 111 123 112 /*! parse structure 124 /*! Create object from the following structure 125 113 126 \code 114 127 class = "MarginalizedParticle"; 115 parameter_pdf = {class = 'epdf_offspring', ...}; 116 bm = {class = 'bm_offspring',...}; 128 parameter_pdf = configuration of bdm::epdf; % any offspring of epdf, bdm::epdf::from_setting 129 --- inherited fields --- 130 bdm::MarginalizedParticleBase::from_setting 117 131 \endcode 118 If rvs are set, then it checks for compatibility. 119 */ 132 */ 120 133 void from_setting(const Setting &set) { 121 134 MarginalizedParticleBase::from_setting ( set ); … … 159 172 UIREGISTER(MarginalizedParticle); 160 173 161 //! class used in PF174 //! Internal class which is used in PF 162 175 class BootstrapParticle : public BM { 163 176 dirac est; … … 193 206 } 194 207 195 /*! parsestructure208 /*! Create object from the following structure 196 209 \code 197 210 class = "BootstrapParticle"; 198 parameter_pdf = {class = 'epdf_offspring', ...}; 199 observation_pdf = {class = 'epdf_offspring',...}; 211 parameter_pdf = configuration of bdm::epdf; % any offspring of epdf, bdm::epdf::from_setting 212 observation_pdf = configuration of bdm::epdf; % any offspring of epdf, bdm::epdf::from_setting 213 --- inherited fields --- 214 bdm::BM::from_setting 200 215 \endcode 201 If rvs are set, then it checks for compatibility.202 216 */ 203 217 void from_setting(const Setting &set) { … … 206 220 obs = UI::build<pdf> ( set, "observation_pdf", UI::compulsory ); 207 221 } 222 208 223 void validate() { 209 224 yrv = obs->_rv(); -
library/bdm/stat/emix.h
r1068 r1077 548 548 weights.validate(); 549 549 } 550 551 /*! Create object from the following structure 552 553 \code 554 class = 'ModelComparator'; 555 --- optional fields --- 556 frg = [...]; % vector of weights 557 --- inherited fields --- 558 bdm::ProdBM::from_setting 559 \endcode 560 */ 550 561 void from_setting(const Setting& set) { 551 562 ProdBM::from_setting(set); 552 563 UI::get(weights.frg, set, "frg",UI::optional); 553 564 } 565 554 566 void to_setting(Setting& set) const { 555 567 ProdBM::to_setting(set); -
library/bdm/stat/exp_family.h
r1068 r1077 111 111 } 112 112 113 /*! Create object from the following structure 114 115 \code 116 class = 'BMEF'; 117 --- optional fields --- 118 frg = []; % forgetting factor 119 frg_sched_factor = []; % factor for scheduling of forgetting factor: a number from [0..1] 120 --- inherited fields --- 121 bdm::BM::from_setting 122 \endcode 123 If the optional fields are not given, they will be filled as follows: 124 \code 125 frg = 1; % default forgetting factor 126 frg_sched_factor = 0; 127 \endcode 128 */ 113 129 void from_setting( const Setting &set) { 114 130 BM::from_setting(set); 115 131 if ( !UI::get ( frg, set, "frg" ) ) 116 132 frg = 1.0; 117 UI::get ( frg_sched_factor, set, "frg_sched_factor",UI::optional ); 133 if ( UI::get ( frg_sched_factor, set, "frg_sched_factor" ) ) 134 frg_sched_factor = 0.0; 118 135 } 119 136 … … 364 381 * \brief Gauss-inverse-Wishart density stored in LD form 365 382 366 * For \f$p\f$-variate densities, given rv.count() should be \f$p \times\f$ V.rows().383 * For \f$p\f$-variate densities, given rv.count() should be \f$p imes\f$ V.rows(). 367 384 * 368 385 */ … … 402 419 403 420 void factorize ( mat &M, ldmat &Vz, ldmat &Lam ) const; 404 //! LS estimate of \f$ \theta\f$421 //! LS estimate of \f$ heta\f$ 405 422 vec est_theta() const; 406 423 … … 830 847 UI::save( &est, set, "prior" ); 831 848 } 849 850 /*! Create object from the following structure 851 852 \code 853 class = 'MultiBM'; 854 prior = configuration of bdm::eDirich; % any offspring of eDirich, bdm::eDirich::from_setting 855 --- inherited fields --- 856 bdm::BMEF::from_setting 857 \endcode 858 */ 832 859 void from_setting (const Setting &set ) { 833 860 BMEF::from_setting ( set ); … … 2062 2089 }; 2063 2090 2064 //! \todo unify this stuff with to_string()2091 //! odo unify this stuff with to_string() 2065 2092 template<class sq_T> 2066 2093 std::ostream &operator<< ( std::ostream &os, mlnorm<sq_T> &ml ) {