Changeset 948 for library/doc/tutorial
- Timestamp:
- 05/18/10 16:54:25 (15 years ago)
- Location:
- library/doc/tutorial
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
library/doc/tutorial/000install.dox
r944 r948 15 15 \li svn checkout http://mys.utia.cas.cz:1800/svn/mixpp/applications/bdmtoolbox/ into your local directory of your choice (this will be denoted \<toolbox_dir\>) 16 16 \li or download a prepared zip file from http://staff.utia.cas.cz/smidl/Public/bdmtoolbox_win32.zip and extract it to any directory (will be denoted \<toolbox_dir\>) 17 \li open matlab and type: 17 \li open matlab and type: 18 18 \code 19 19 >> addpath <toolbox_dir>/mex; … … 21 21 >> addpath <toolbox_dir>/mex_classes 22 22 \endcode 23 for downloaded win32 version of the toolbox. When compiling from sources, the mex files may be located in Debug of Release directories. Check where 24 the latest compiled files are and add apropriate path. E.g. for Windown and Mac: 25 \code 26 >> addpath <toolbox_dir>/mex; 27 >> addpath <toolbox_dir>/mex/Debug; 28 >> addpath <toolbox_dir>/mex_classes 29 \endcode 30 For linux, the default build dir is \<toolbox_dir\>/mex, hence only me and mex_classes need to be in the path. 23 31 \li the toolbox is ready to be used, test it e.g. by: 24 32 \code >> cd tutorial/userguide; -
library/doc/tutorial/007userguide_pdf.dox
r944 r948 5 5 6 6 The tutorial is written for the BDM toolbox, if you are interested in use of C++ classes see class reference pages. 7 8 Table of content: 9 - \ref ug_pdf_create 10 - \ref ug_pdf_marg 11 - \ref ug_pdf_cond 12 - \ref ug_pdf_fnc 13 - \ref ug_pdf_mex 7 14 8 15 \section ug_pdf_create Using built-in pdfs … … 20 27 \li mu denotes mean value 21 28 \li R denotes variance (written in full matrix regardles of the used decomposition), 29 \li parameters mu and R are vector and matrix, respectively. They can be given directly (as in Nab.mu) or as a result of arbitrary matlab function, (as in Nab.R) 22 30 \li rv denotes names assigned to the variables. RV is more complicated structure, but here it is sufficient to use default values. 23 31 \li rv is an optional parameter, some operations do not need it, such as sampling or evaluation of moments -
library/doc/tutorial/01userguide_sim.dox
r947 r948 2 2 \page userguide_sim BDM Use - System, Data, Simulation 3 3 4 This section serves as introduction to the scenario of data simulation. Since it is the simpliest of all scenarios defined in \ref userguide0 it also serves as introduction to configuration of an experiment (see \ref ui) and basic decision making objects (bdm::RV and bdm::DS). 5 6 All experiments are demonstarted on mex file \c simulator, which is also available as a standalone application. 4 This section serves as introduction to the scenario of data simulation. Since it is the simplest of all scenarios defined in \ref userguide0 it also serves as introduction to configuration of an experiment (see \ref ui) and basic decision making objects (bdm::RV and bdm::DS). 5 6 All experiments are demonstrated on mex file \c simulator, which is also available as a standalone application. 7 8 Table of contents: 9 \section ug_sim_config 10 \section ug_sim 11 \section ug_memds 12 \section ug_rvs 13 \subsection ug_rv_connect 14 \section ug_pdfds 15 \section ug_arx_sim 16 \subsection ug_ini 17 \section ug_store 7 18 8 19 … … 13 24 Specific treatment was developed for objects. Since BDM is designed as object oriented library, the configuration was designed to honor the rule of inheritance. That is, offspring of a class can be used in place of its predecessor. Hence, objects (instances of classes) are configured by a structure with compulsory field \c class. This is a string variable corresponding to the name of the class to be used. This information is stored in Matlab structures (or objects, see section on Matlab extensions). 14 25 15 Adva cnded users can find more information in (\ref ui).26 Advanced users can find more information in (\ref ui). 16 27 17 28 \subsection ug_first First experiment … … 24 35 which can be found in file bdmtoolbox/tutorials/userguide/memds_example.m. 25 36 26 The code above is the minimum necessary information to run scenario \c simulator in matlab.27 To actually do so, make sure that matlab paths are correctly set, as described in \ref install.37 The code above is the minimum necessary information to run scenario \c simulator in Matlab. 38 To actually do so, make sure that Matlab paths are correctly set, as described in \ref install. 28 39 29 40 The expected result for Matlab is: … … 62 73 -# store log of its activity into dedicated logger. 63 74 64 No f ruther specification, e.g. if the data are pre-recorded or computed on-the-fly, are given.75 No further specification, e.g. if the data are pre-recorded or computed on-the-fly, are given. 65 76 For a list of available DataSources, see ... 66 77 … … 71 82 72 83 Operation of such object is trivial, the data are stored as a matrix and the general operations defined above are specialized as follows: 73 -# data observed at time \f$ t \f$ are columns of the matrix, getdata() r uturns current column,84 -# data observed at time \f$ t \f$ are columns of the matrix, getdata() returns current column, 74 85 -# time step itself is performed by increasing the column index, 75 86 -# each row is named as "ch0","ch1",... 76 87 77 This is the default b ahavior. It can be customized using the UI mechanism. Full list of options is:88 This is the default behavior. It can be customized using the UI mechanism. Full list of options is: 78 89 \code 79 90 DS.class = 'MemDS'; … … 99 110 100 111 It is used for: 101 - des ription of RV in pdfs, ways how to define marginalization and conditioning,112 - description of RV in pdfs, ways how to define marginalization and conditioning, 102 113 - connection between source of data and computational objects that use them, 103 114 - connection <b>time</b>, more exactly time shift from \f$ t \f$, defaults to 0. 104 115 105 For example, the estimators will request the data from the above mentioned data source by asking for rv 'ch0'. If a more meanin ful names are available, the fields drv can be added to read:116 For example, the estimators will request the data from the above mentioned data source by asking for rv 'ch0'. If a more meaningful names are available, the fields drv can be added to read: 106 117 \code 107 118 DS.class='MemDS'; … … 109 120 DS.drv = RV('y'); 110 121 \endcode 111 Data from th sidata source will be available when estimators ask for rv 'y'.122 Data from this data source will be available when estimators ask for rv 'y'. 112 123 113 124 \subsection ug_rv_connect Storing results 114 125 115 results of an experiment can be stored in many ways. This functionality was abstracted into a class called logger. Exact form of the stored resul s is chosen by choosing appropriate class.116 For example, \c stdlog writes all output in the console, \c dirfilelog writes all data in the dirfilelog format for high-speed data processing, \c mexlog writes data into matlab structure.126 results of an experiment can be stored in many ways. This functionality was abstracted into a class called logger. Exact form of the stored results is chosen by choosing appropriate class. 127 For example, \c stdlog writes all output in the console, \c dirfilelog writes all data in the dirfilelog format for high-speed data processing, \c mexlog writes data into Matlab structure. 117 128 The \c mexlog is the default option in bdmtoolbox. 118 129 119 Connection between computational blocks and loggers is controlled by structure called \c log_level which govern es the level of details to be logged.130 Connection between computational blocks and loggers is controlled by structure called \c log_level which governs the level of details to be logged. 120 131 A standard Data source has two levels, \c logdt and \c logut which means "log all outputs, dt" and "log all inputs, ut". 121 132 Readers familiar with Simulink environment may look at the RV as being unique identifiers of inputs and outputs of simulation blocks. The inputs are connected automatically with the outputs with matching RV. This view is however, very incomplete, RV have more roles than this. … … 134 145 \f] 135 146 136 The datasource itself, i.e. the instanc of \c EpdfDS can be then configured via:147 The datasource itself, i.e. the instance of \c EpdfDS can be then configured via: 137 148 \code 138 149 DS.class = 'pdfDS'; … … 150 161 151 162 If the task was only to generate random realizations, this would indeed be a very clumsy way of doing it. 152 However, the power of the proposed approach will be reve lead in more demanding examples, one of which follows next.163 However, the power of the proposed approach will be revealed in more demanding examples, one of which follows next. 153 164 154 165 By default, data from this datasouce will be named after the rvs in given by the pdfs. When pdf with no rv is used, drv of the data source is set again to 'ch0'. … … 164 175 We need to handle two issues: 165 176 -# extra unsimulated variable \f$ u \f$, 166 -# time delay es of the values.177 -# time delays of the values. 167 178 168 179 The first issue can be handled in two ways. First, \f$ u \f$ can be considered as input and as such it could be externally given to the datasource. This solution is used in scenario \c closedloop. … … 202 213 Explanation of this example will require few remarks: 203 214 - class of the \c fy object is 'mlnorm\<ldmat\>' which is Normal pdf with mean value given by linear function, and covariance matrix stored in LD decomposition, see bdm::mlnorm for details. 204 - naming convention 'mlnorm\<ldmat\>' relates to the concept of templates in C++. For those unfamiliar with this concept, it is basical y a way how to share code for different flavours of the same object. Note that mlnorm exist in three versions: mlnorm\<ldmat\>, mlnorm<chmat>, mlnorm<fsqmat>. Those classes act identically the only difference is that the internal data are stored either in LD decomposition, choleski decomposition or full matrices, respectively.215 - naming convention 'mlnorm\<ldmat\>' relates to the concept of templates in C++. For those unfamiliar with this concept, it is basically a way how to share code for different flavors of the same object. Note that mlnorm exist in three versions: mlnorm\<ldmat\>, mlnorm<chmat>, mlnorm<fsqmat>. Those classes act identically the only difference is that the internal data are stored either in LD decomposition, choleski decomposition or full matrices, respectively. 205 216 - the same concept is used for enorm, where enorm<chmat> and enorm<fsqmat> are also possible. In this particular use, these objects are equivalent. In specific situation, e.g. Kalman filter implemented on Choleski decomposition (bdm::KalmanCh), only enorm<chmat> is approprate. 206 217 - class 'mprod' represents the chain rule of probability, see \ref ug_pdf_cond. 207 218 208 The code above can be immediatel ly run, usinthe same execution sequence of \c estimator as above.219 The code above can be immediately run, using the same execution sequence of \c estimator as above. 209 220 210 221 \subsection ug_ini Initializing simulation … … 217 228 218 229 The values of \c init_values will be copied to places in history identified by corresponding values of \c init_rv. 219 Initial data is not checked for completeness, i.e. values of random variables missing from \c init_rv (in this case all occur ences of \f$ u \f$) are still initialized to 0.230 Initial data is not checked for completeness, i.e. values of random variables missing from \c init_rv (in this case all occurrences of \f$ u \f$) are still initialized to 0. 220 231 221 232 \section ug_store Storing results of simulation … … 226 237 For example, the output of \c MemDS can be stored as an .it file (filename is specified in configuration structure) which can be later read by bdm::ITppFileDS. 227 238 228 In matlab, the output of mexlog is a structure of vectors or matrices. The results can be saved in a matlab file using:239 In Matlab, the output of mexlog is a structure of vectors or matrices. The results can be saved in a Matlab file using: 229 240 \code 230 241 Data=[M.y; M.u]; -
library/doc/tutorial/02userguide_estim.dox
r944 r948 2 2 \page userguide_estim BDM Use - Estimation and Bayes Rule 3 3 4 Baysian theory is predominantly used in system identification, or estimation problems. 5 This section is concerned with recursive estimation, as implemneted in prepared scenario \c estimator. 4 Bayesian theory is predominantly used in system identification, or estimation problems. 5 This section is concerned with recursive estimation, as implemented in prepared scenario \c estimator. 6 7 Table of contents: 8 \ref ug2_theory 9 \ref ug2_arx_basic 10 \ref ug2_model_sel 11 \ref ug2_bm_composition 12 \ref ug_est_ext 6 13 7 14 The function of the \c estimator is graphically illustrated: … … 31 38 - <b> Bayes rule </b> as defined above, operation bdm::BM::bayes() which expects to get the current data record \c dt, \f$ d_t \f$ 32 39 - <b> evidence </b> i.e. numerical value of \f$ f(d_t|d_1\ldots d_{t-1})\f$ as a typical side-product, since it is required in denominator of the above formula. 33 For some models, computation of this value may require extra effort, and can be swit hed off.40 For some models, computation of this value may require extra effort, and can be switched off. 34 41 - <b> prediction </b> the object has enough information to create the one-step ahead predictor, i.e. \f[ f(d_{t+1}| d_1 \ldots d_{t}), \f] 35 42 36 43 Implementation of these operations is heavily dependent on the specific class of prior pdf, or its approximations. We can identify only a few principal approaches to this problem. For example, analytical estimation which is possible within sufficient the Exponential Family, or estimation when both prior and posterior are approximated by empirical densities. 37 These approaches are first level of descendants of class \c BM, classes bdm::BMEF and bdm::PF, re pectively.44 These approaches are first level of descendants of class \c BM, classes bdm::BMEF and bdm::PF, respectively. 38 45 39 46 \section ug2_arx_basic Estimation of ARX models … … 51 58 This is the minimal configuration of an ARX estimator. 52 59 53 The first three fi leds are self explanatory, they identify which data are predicted (field \c rv) and which are in regressor (field \c rgr).60 The first three fields are self explanatory, they identify which data are predicted (field \c rv) and which are in regresor (field \c rgr). 54 61 The field \c log_level is a string of options passed to the object. In particular, class \c BM understand only options related to storing results: 55 62 - logbounds - store also lower and upper bounds on estimates (obtained by calling BM::posterior().qbounds()), … … 66 73 In Bayesian framework, model selection is done via comparison of evidence (marginal likelihood) of the recorded data. See [some theory]. 67 74 68 A trivial exam mple how this can be done is presented in file bdmtoolbox/tutorial/userguide/arx_selection_example.m. The code extends the basic A1 object as follows:75 A trivial example how this can be done is presented in file bdmtoolbox/tutorial/userguide/arx_selection_example.m. The code extends the basic A1 object as follows: 69 76 \code 70 77 A2=A1; … … 78 85 - A3 which is the same as A2, but assumes time-variant parameters with forgetting factor 0.95. 79 86 80 Since all estimator were configured to store values of marginal log-likelihood, we can easily compare them by computin ttotal log-likelihood for each of them and converting them to probabilities. Typically, the results should look like:87 Since all estimator were configured to store values of marginal log-likelihood, we can easily compare them by computing total log-likelihood for each of them and converting them to probabilities. Typically, the results should look like: 81 88 \code 82 89 Model_probabilities = … … 100 107 \section ug2_bm_composition Composition of estimators 101 108 102 Similarly to pdfs which could be composed via \c mprod, the Bayesian models can be composed toget rer. However, justification of this step is less clear than in the case of epdfs.109 Similarly to pdfs which could be composed via \c mprod, the Bayesian models can be composed together. However, justification of this step is less clear than in the case of epdfs. 103 110 104 111 One possible theoretical base of composition is the Marginalized particle filter, which splits the prior and the posterior in two parts: … … 166 173 \image latex frg_example.png "Typical run of tutorial/userguide/frg_example.m" width=\linewidth 167 174 168 Note: error bars in this case are not directly comparable with those of previous examples. The MPF class implements the qbounds function as minimum and maximum of bounds in the con didered set (even if its weight is extreemly small). Hence, the bounds of the MPF are probably larger than it should be. Nevertheless, they provide great help when designing and tuning algorithms.175 Note: error bars in this case are not directly comparable with those of previous examples. The MPF class implements the qbounds function as minimum and maximum of bounds in the considered set (even if its weight is extremely small). Hence, the bounds of the MPF are probably larger than it should be. Nevertheless, they provide great help when designing and tuning algorithms. 169 176 170 177 \section ug_est_ext Matlab extensions of the Bayesian estimators … … 178 185 In order to create a new extension of an estimator, copy file with class mexLaplaceBM.m and redefine the methods therein. If needed create new classes for pdfs by inheriting from mexEpdf, it the same way as in the mexLaplace.m example class. 179 186 180 For olist of all estimators, see \ref app_base.187 For list of all estimators, see \ref app_base. 181 188 */ -
library/doc/tutorial/030userguide3.dox
r704 r948 1 1 /*! 2 \page userguide 3BDM Use - Control and Design of Decision Making Strategy2 \page userguide_ctrl BDM Use - Control and Design of Decision Making Strategy 3 3 4 4 Bayesian estimation as introduced in Section \ref userguide2 is a special case of Decision Strategy, see. .... 5 5 A more demanding scenario is to design a control strategy that will influence the system operating under uncertainty, this is implemented as scenario \c closedloop. 6 7 Table of content: 8 \ref ug3_theory 9 \ref ug3_arx_basic 10 \ref ug3_arx_distributed 6 11 7 12 The function of the \c closedloop is graphically illustrated: