1 | /*! |
---|
2 | \file |
---|
3 | \brief UI for Common probability density functions |
---|
4 | \author Vaclav Smidl. |
---|
5 | |
---|
6 | ----------------------------------- |
---|
7 | BDM++ - C++ library for Bayesian Decision Making under Uncertainty |
---|
8 | |
---|
9 | Using IT++ for numerical operations |
---|
10 | ----------------------------------- |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef DS_UI_H |
---|
14 | #define DS_UI_H |
---|
15 | |
---|
16 | |
---|
17 | #include "libDS.h" |
---|
18 | #include "stat/loggers_ui.h" |
---|
19 | |
---|
20 | /*! UI for mgnorm |
---|
21 | |
---|
22 | The mgnorm is constructed from a structure with fields: |
---|
23 | \code |
---|
24 | system = { |
---|
25 | type = "mgnorm"; |
---|
26 | // function for mean value evolution |
---|
27 | g = {type="fnc"; ... } |
---|
28 | |
---|
29 | // variance |
---|
30 | R = [1, 0, |
---|
31 | 0, 1]; |
---|
32 | // --OR -- |
---|
33 | dR = [1, 1]; |
---|
34 | |
---|
35 | // == OPTIONAL == |
---|
36 | |
---|
37 | // description of y variables |
---|
38 | y = {type="rv"; names=["y", "u"];}; |
---|
39 | // description of u variable |
---|
40 | u = {type="rv"; names=[];} |
---|
41 | }; |
---|
42 | \endcode |
---|
43 | |
---|
44 | Result if |
---|
45 | */ |
---|
46 | class UImgnorm : public UIbuilder { |
---|
47 | public: |
---|
48 | UImgnorm() :UIbuilder ( "mgnorm" ) {}; |
---|
49 | bdmroot* build ( Setting &S ) const { |
---|
50 | mgnorm<chmat>* mgn; |
---|
51 | fnc* g; UIbuild ( S["g"],g ); |
---|
52 | |
---|
53 | mat R; |
---|
54 | if ( S.exists ( "dR" ) ) {R=diag ( getvec ( S["dR"] ) );} |
---|
55 | else { |
---|
56 | if ( S.exists ( "R" ) ) {R=getmat ( S["R"],g->dimension() );} |
---|
57 | } |
---|
58 | |
---|
59 | mgn->set_parameters(g,R); |
---|
60 | return mgn; |
---|
61 | }; |
---|
62 | }; |
---|
63 | |
---|
64 | UIREGISTER ( UImgnorm); |
---|
65 | |
---|
66 | /*! UI for migamma_ref |
---|
67 | |
---|
68 | The migamma_ref is constructed from a structure with fields: |
---|
69 | \code |
---|
70 | system = { |
---|
71 | type = "migamma_ref"; |
---|
72 | ref = [1e-5; 1e-5; 1e-2 1e-3]; // reference vector |
---|
73 | l = 0.999; // constant l |
---|
74 | k = 0.1; // constant k |
---|
75 | |
---|
76 | // == OPTIONAL == |
---|
77 | // description of y variables |
---|
78 | y = {type="rv"; names=["y", "u"];}; |
---|
79 | // description of u variable |
---|
80 | u = {type="rv"; names=[];} |
---|
81 | }; |
---|
82 | \endcode |
---|
83 | |
---|
84 | Result if |
---|
85 | */ |
---|
86 | class UImigamma_ref : public UIbuilder { |
---|
87 | public: |
---|
88 | UImigamma_ref() :UIbuilder ( "migamma_ref" ) {}; |
---|
89 | bdmroot* build ( Setting &S ) const { |
---|
90 | migamma_ref* mig=new migamma_ref; |
---|
91 | |
---|
92 | mig->set_parameters(S["k"],getvec(S["ref"]),S["l"]); |
---|
93 | return mig; |
---|
94 | }; |
---|
95 | }; |
---|
96 | UIREGISTER ( UImigamma_ref ); |
---|
97 | |
---|
98 | |
---|
99 | /*! UI for mlognorm |
---|
100 | |
---|
101 | The mlognorm is constructed from a structure with fields: |
---|
102 | \code |
---|
103 | system = { |
---|
104 | type = "mlognorm"; |
---|
105 | k = 0.1; // constant k |
---|
106 | mu0 = [1., 1.]; |
---|
107 | |
---|
108 | // == OPTIONAL == |
---|
109 | // description of y variables |
---|
110 | y = {type="rv"; names=["y", "u"];}; |
---|
111 | // description of u variable |
---|
112 | u = {type="rv"; names=[];} |
---|
113 | }; |
---|
114 | \endcode |
---|
115 | |
---|
116 | */ |
---|
117 | class UImlognorm : public UIbuilder { |
---|
118 | public: |
---|
119 | UImlognorm() :UIbuilder ( "mlognorm" ) {}; |
---|
120 | bdmroot* build ( Setting &S ) const { |
---|
121 | mlognorm* mln=new mlognorm; |
---|
122 | |
---|
123 | vec mu0=getvec(S["mu0"]); |
---|
124 | mln->set_parameters(mu0.length(),S["k"]); |
---|
125 | mln->condition(mu0); |
---|
126 | return mln; |
---|
127 | }; |
---|
128 | }; |
---|
129 | UIREGISTER ( UImlognorm ); |
---|
130 | |
---|
131 | #endif // DS_UI_H |
---|