Changeset 1077 for library

Show
Ignore:
Timestamp:
06/10/10 21:40:09 (14 years ago)
Author:
mido
Message:

another update of doc - all bayesian models until bdm::MultiModel? finished
also MixEF::MixEF_options renamed just to MixEF::Options

Location:
library/bdm
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/bdmbase.h

    r1068 r1077  
    12791279    //! \var log_level_enums logbounds 
    12801280    //! log lower and upper bounds of estimates 
     1281 
    12811282    LOG_LEVEL(BM,logfull,logevidence,logbounds); 
    12821283 
     
    14161417 
    14171418    //!@} 
    1418     //! \brief Read names of random variables from setting 
    1419     /*! 
    1420     reading structure: 
     1419 
     1420    /*! Create object from the following structure 
    14211421    \TODO check if not remove... rv... 
     1422 
    14221423    \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 
    14271432    \endcode 
    14281433    */ 
  • library/bdm/estim/arx.h

    r1064 r1077  
    2727Regression of the following kind: 
    2828\f[ 
    29 y_t = \theta_1 \psi_1 + \theta_2 + \psi_2 +\ldots + \theta_n \psi_n + r e_t 
     29y_t =     heta_1 \psi_1 +     heta_2 + \psi_2 +\ldots +     heta_n \psi_n + r e_t 
    3030\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: 
     31where 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: 
    3232\f[ 
    3333e_t \sim \mathcal{N}(0,1). 
     
    3939\include arx_simple.cpp 
    4040 
    41         \todo sort out constant terms - bayes should accept vec without additional 1s 
     41            odo sort out constant terms - bayes should accept vec without additional 1s 
    4242*/ 
    4343class ARX: public BMEF { 
     
    132132    //!@} 
    133133 
    134     /*! UI for ARX estimator 
     134    /*! Create object from the following structure 
    135135 
    136136    \code 
    137137    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 
    150151    \endcode 
    151152    */ 
     
    208209SHAREDPTR ( ARX ); 
    209210 
    210 /*! ARX model conditined by knowledge of the forgetting factor 
    211 \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] 
    212213 
    213214The symbol \f$ \phi \f$ is assumed to be the last of the conditioning variables. 
  • library/bdm/estim/kalman.h

    r1064 r1077  
    137137        return est; 
    138138    } 
    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    */ 
    154150    void from_setting ( const Setting &set ) { 
    155151        StateSpace<sq_T>::from_setting ( set ); 
     
    242238    void bayes ( const vec &yt, const vec &cond = empty_vec ); 
    243239 
     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    */ 
    244248    void from_setting ( const Setting &set ) { 
    245249        Kalman<chmat>::from_setting ( set ); 
    246         validate(); 
    247     } 
     250    } 
     251 
    248252    void validate() { 
    249253        Kalman<chmat>::validate(); 
     
    283287        return est._R().to_mat(); 
    284288    } 
     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    */ 
    285313    void from_setting ( const Setting &set ) { 
    286314        BM::from_setting ( set ); 
     
    365393    //! Here dt = [yt;ut] of appropriate dimensions 
    366394    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    */ 
    368418    void from_setting ( const Setting &set ); 
    369419 
     
    481531State-Space representation of multivariate autoregressive model. 
    482532The 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] 
    484534where \f$ k,l,m \f$ are maximum delayes of corresponding variables in the regressor. 
    485535 
  • library/bdm/estim/mixtures.cpp

    r1064 r1077  
    3939        //Coms ( i )->flatten ( SharpCom.get(), 1.0/Coms.length() ); 
    4040    } 
    41     MixEF_options old_opt =options; 
    42     MixEF_options ini_opt=options; 
     41    Options old_opt =options; 
     42    Options ini_opt=options; 
    4343    ini_opt.method = EM; 
    4444    ini_opt.max_niter= 1; 
  • library/bdm/estim/mixtures.h

    r1066 r1077  
    3131mixture models of the following kind: 
    3232\f[ 
    33 f(y_t|\psi_t, \Theta) = \sum_{i=1}^{n} w_i f(y_t|\psi_t, \theta_i) 
     33f(y_t|\psi_t,     heta) = \sum_{i=1}^{n} w_i f(y_t|\psi_t,     heta_i) 
    3434\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$. 
     35where  \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$. 
    3636 
    3737The 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. 
     
    5050class MixEF: public BMEF { 
    5151protected: 
    52     //! Models for Components of \f$\theta_i\f$ 
     52    //! Models for Components of \f$    heta_i\f$ 
    5353    Array<BMEF*> Coms; 
    5454    //! Statistics for weights 
     
    7272    ////!indices of component rvc in common rvc 
    7373 
    74     class MixEF_options: public root { 
     74    class Options: public root { 
    7575    public: 
    7676        //! Flag for a method that is used in the inference 
     
    8080        int max_niter; 
    8181 
    82         MixEF_options():method(QB),max_niter(10) {}; 
    83  
    84         //! Settings for MixEF 
    85         /*! 
     82        Options():method(QB),max_niter(10) {}; 
     83 
     84         /*! Create object from the following structure 
     85 
    8686        \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'; 
    8997        \endcode 
    9098        */ 
     
    98106            UI::get(max_niter,set,"max_niter",UI::optional); 
    99107        }; 
     108 
    100109        void to_setting(Setting &set)const { 
    101110            string meth=(method==EM ? "EM" : "QB"); 
     
    105114    }; 
    106115 
    107     MixEF_options options; 
     116    Options options; 
    108117public: 
    109118    //! Full constructor 
     
    170179        UI::save (options, set, "options"); 
    171180    } 
    172     /*! \brief reads data from setting 
     181 
     182    /*! Create object from the following structure 
     183 
    173184    \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 
    178192    \endcode 
    179193    */ 
     
    187201UIREGISTER ( MixEF ); 
    188202 
     203//! \brief TODO DOCUMENTATION IS MISSING HERE 
    189204class ARXprod: public ProdBMBase { 
    190205    Array<shared_ptr<ARX> > arxs; 
  • library/bdm/estim/particles.h

    r1068 r1077  
    6767        } 
    6868    } 
     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    */ 
    6980    void from_setting(const Setting &set) { 
    7081        BM::from_setting ( set ); 
     
    7889}; 
    7990 
     91//! \brief Internal class used in PF (surely?) 
    8092class MarginalizedParticle : public MarginalizedParticleBase { 
    8193protected: 
     
    110122    } 
    111123 
    112     /*! parse structure 
     124    /*! Create object from the following structure 
     125 
    113126    \code 
    114127    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 
    117131    \endcode 
    118     If rvs are set, then it checks for compatibility. 
    119     */ 
     132    */     
    120133    void from_setting(const Setting &set) { 
    121134        MarginalizedParticleBase::from_setting ( set ); 
     
    159172UIREGISTER(MarginalizedParticle); 
    160173 
    161 //! class used in PF 
     174//! Internal class which is used in PF 
    162175class BootstrapParticle : public BM { 
    163176    dirac est; 
     
    193206    } 
    194207 
    195     /*! parse structure 
     208    /*! Create object from the following structure 
    196209    \code 
    197210    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 
    200215    \endcode 
    201     If rvs are set, then it checks for compatibility. 
    202216    */ 
    203217    void from_setting(const Setting &set) { 
     
    206220        obs = UI::build<pdf> ( set, "observation_pdf", UI::compulsory ); 
    207221    } 
     222 
    208223    void validate() { 
    209224        yrv = obs->_rv(); 
  • library/bdm/stat/emix.h

    r1068 r1077  
    548548        weights.validate(); 
    549549    } 
     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    */ 
    550561    void from_setting(const Setting& set) { 
    551562        ProdBM::from_setting(set); 
    552563        UI::get(weights.frg, set, "frg",UI::optional); 
    553564    } 
     565 
    554566    void to_setting(Setting& set) const { 
    555567        ProdBM::to_setting(set); 
  • library/bdm/stat/exp_family.h

    r1068 r1077  
    111111    } 
    112112 
     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    */ 
    113129    void from_setting( const Setting &set) { 
    114130        BM::from_setting(set); 
    115131        if ( !UI::get ( frg, set, "frg" ) ) 
    116132            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; 
    118135    } 
    119136 
     
    364381* \brief Gauss-inverse-Wishart density stored in LD form 
    365382 
    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(). 
    367384* 
    368385*/ 
     
    402419 
    403420    void factorize ( mat &M, ldmat &Vz, ldmat &Lam ) const; 
    404     //! LS estimate of \f$\theta\f$ 
     421    //! LS estimate of \f$    heta\f$ 
    405422    vec est_theta() const; 
    406423 
     
    830847        UI::save( &est, set, "prior" ); 
    831848    } 
     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    */ 
    832859    void from_setting (const Setting &set )  { 
    833860        BMEF::from_setting ( set ); 
     
    20622089}; 
    20632090 
    2064 //! \todo unify this stuff with to_string() 
     2091//!     odo unify this stuff with to_string() 
    20652092template<class sq_T> 
    20662093std::ostream &operator<< ( std::ostream &os,  mlnorm<sq_T> &ml ) {