root/library/bdm/estim/arx_ext.h @ 1064

Revision 1064, 2.5 kB (checked in by mido, 14 years ago)

astyle applied all over the library

Line 
1/*!
2  \file
3  \brief Bayesian Filtering for extensions of autoregressive (ARX) model
4  \author Vaclav Smidl.
5
6*/
7
8#ifndef AREX_H
9#define AREX_H
10
11#include "../math/functions.h"
12#include "arx.h"
13
14namespace bdm {
15
16/*!
17* \brief Non-linear transformation + Gaussian noise
18
19Regression of the following kind:
20\f[
21y_t = g(\psi_t ) + r e_t
22\f]
23where unknown parameters \c rv are \f$[r]\f$, regression vector \f$\psi_t=\psi(y_{1:t},u_{1:t})\f$ is propagated through a known function \c g. Distrubances \f$e_t\f$ are supposed to be normally distributed:
24\f[
25e_t \sim \mathcal{N}(0,1).
26\f]
27
28*/
29class ARXg: public ARX {
30protected:
31    //! function g
32    shared_ptr<fnc> g;
33public:
34    //! \name Constructors
35    //!@{
36    ARXg (): ARX() {}
37    ARXg (const ARXg &A0): ARX(A0),g(A0.g) {}
38    ARXg* _copy() const {
39        return new ARXg(*this);
40    }
41    //!@}
42
43    //!\name Mathematical operations
44    //!@{
45
46    //! Weighted Bayes \f$ dt = [y_t psi_t] \f$.
47    void bayes_weighted ( const vec &yt, const vec &cond = empty_vec, const double w = 1.0 ) {
48        int dimc_store =dimc;
49        dimc =0;
50        ARX::bayes_weighted(yt - g->eval(cond), empty_vec, w);
51        dimc = dimc_store;
52    };
53    //!@}
54
55    /*! UI for ARXg estimator
56
57    \code
58    class = 'ARXg';
59    yrv   = RV({names_of_dt} )                 // description of output variables
60    rgr   = RV({names_of_regressors}, [-1,-2]} // description of regressor variables
61    constant = 1;                              // 0/1 switch if the constant term is modelled or not
62    g     = {class='my_function',...}          // function transforming regressor
63
64    --- optional ---
65    prior = {class='egiw',...};                // Prior density, when given default is used instead
66    alternative = {class='egiw',...};          // Alternative density in stabilized estimation, when not given prior is used
67
68    frg   = 1.0;                               // forgetting, default frg=1.0
69
70    rv    = RV({names_of_parameters}}          // description of parametetr names
71    \endcode
72    */
73    void from_setting ( const Setting &set ) {
74        ARX::from_setting(set);
75        g=UI::build<fnc>(set,"g",UI::compulsory);
76    }
77
78    void validate() {
79        ARX::validate();//if dimc not set set it from V
80        bdm_assert(g->dimension()==dimensiony(),"incompatible g");
81        bdm_assert(g->dimensionc()==dimensionc(),"incompatible g");
82    }
83
84    void to_setting ( Setting &set ) const
85    {
86        ARX::to_setting( set ); // takes care of rv, yrv, rvc
87        UI::save(g,set,"g");
88    }
89};
90UIREGISTER ( ARXg );
91SHAREDPTR ( ARXg );
92
93};
94#endif // AREX_H
95
Note: See TracBrowser for help on using the browser.