| 1 | /*! | 
|---|
| 2 | \page user_guide2 BDM Use - Estimation and Bayes Rule | 
|---|
| 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. | 
|---|
| 6 |  | 
|---|
| 7 | The function of the \c estimator is graphically illustrated: | 
|---|
| 8 | \dot | 
|---|
| 9 | digraph estimation{ | 
|---|
| 10 |         node [shape=box]; | 
|---|
| 11 |         {rank="same"; "Data Source"; "Bayesian Model"} | 
|---|
| 12 |         "Data Source" -> "Bayesian Model" [label="data"]; | 
|---|
| 13 |         "Bayesian Model" -> "Result Logger" [label="estimation\n result"]; | 
|---|
| 14 |         "Data Source" -> "Result Logger" [label="Simulated\n data"]; | 
|---|
| 15 | } | 
|---|
| 16 | \enddot | 
|---|
| 17 |  | 
|---|
| 18 | Here, | 
|---|
| 19 | \li Data Source is an object (class DS) providing sequential data, \f$ [d_1, d_2, \ldots d_t] \f$. | 
|---|
| 20 | \li Bayesian Model is an object (class BM) performing Bayesian filtering, | 
|---|
| 21 | \li Result Logger is an object (class logger) dedicated to storing important data from the experiment. | 
|---|
| 22 |  | 
|---|
| 23 | Since objects  datasource and the logger has already been introduced in section \ref user_guide, it remains to introduce  | 
|---|
| 24 | object \c Bayesian \c Model (bdm::BM). | 
|---|
| 25 |  | 
|---|
| 26 | \section theory Bayes rule and estimation | 
|---|
| 27 | The object bdm::BM is basic software image of the Bayes rule: | 
|---|
| 28 | \f[ f(x_t|d_1\ldots d_t) \propto f(d_t|x_t,d_1\ldots d_{t-1}) f(x_t| d_1\ldots d_{t-1}) \f] | 
|---|
| 29 |  | 
|---|
| 30 | Since this operation can not be defined universally, the object is defined as abstract class with methods for: | 
|---|
| 31 |  - <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 |  - <b> log-likelihood </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, hence it computation can be suppressed by setting BM::set_evalll(false). | 
|---|
| 34 |  - <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 |         this object can be either created bdm::BM::predictor(), sometimes it is enought only a few values of prediction hence construction of the full predictor would be too expensive operation. For this situation were designed cheaper operations bdm::BM::logpred() or bdm::BM::epredictor(). | 
|---|
| 36 | These are only basic operations, see full documentation for full range of defined operations. | 
|---|
| 37 |          | 
|---|
| 38 | These operation are abstract, i.e. not implemented for the general class.  | 
|---|
| 39 | 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.  | 
|---|
| 40 | These approaches are first level of descendants of class \c BM, classes bdm::BMEF and bdm::PF, repectively. | 
|---|
| 41 |  | 
|---|
| 42 | Variants of these approaches are implemented as descendats of these level-two classes. This way, each estimation method (represented a class) is fitted in its place in the tree of approximations. This is useful even from software point of view, since related approximations have common methods and data fields. | 
|---|
| 43 |  | 
|---|
| 44 | \section arx Estimation of ARX models | 
|---|
| 45 |  | 
|---|
| 46 | Autoregressive models has already been introduced in \ref ug_arx_sim where their simulator has been presented. | 
|---|
| 47 | We will use the datasource defined there to provide data for estimation. | 
|---|
| 48 |  | 
|---|
| 49 | The following code is from bdmtoolbox/tutorial/userguide/arx_basic_example | 
|---|
| 50 | \code | 
|---|
| 51 | A1.class = 'ARX'; | 
|---|
| 52 | A1.rv = y; | 
|---|
| 53 | A1.rgr = RVtimes({y,y},[-3,-1]) ; | 
|---|
| 54 | \endcode  | 
|---|
| 55 | Using the same logic as before,  | 
|---|
| 56 |  | 
|---|
| 57 | */ | 
|---|