1 | <?xml version='1.0' encoding='UTF-8' standalone='no'?> |
---|
2 | <doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.5.6"> |
---|
3 | <compounddef id="arx__test_8cpp" kind="file"> |
---|
4 | <compoundname>arx_test.cpp</compoundname> |
---|
5 | <includes refid="arx_8h" local="no">estim/arx.h</includes> |
---|
6 | <includes refid="libEF_8h" local="no">stat/libEF.h</includes> |
---|
7 | <incdepgraph> |
---|
8 | <node id="810"> |
---|
9 | <label>libBM.h</label> |
---|
10 | <link refid="libBM_8h"/> |
---|
11 | <childnode refid="808" relation="include"> |
---|
12 | </childnode> |
---|
13 | </node> |
---|
14 | <node id="813"> |
---|
15 | <label>../itpp_ext.h</label> |
---|
16 | <link refid="itpp__ext_8h-source"/> |
---|
17 | <childnode refid="808" relation="include"> |
---|
18 | </childnode> |
---|
19 | </node> |
---|
20 | <node id="811"> |
---|
21 | <label>../stat/libEF.h</label> |
---|
22 | <link refid="libEF_8h"/> |
---|
23 | <childnode refid="808" relation="include"> |
---|
24 | </childnode> |
---|
25 | <childnode refid="812" relation="include"> |
---|
26 | </childnode> |
---|
27 | <childnode refid="810" relation="include"> |
---|
28 | </childnode> |
---|
29 | <childnode refid="813" relation="include"> |
---|
30 | </childnode> |
---|
31 | </node> |
---|
32 | <node id="807"> |
---|
33 | <label>estim/arx.h</label> |
---|
34 | <link refid="arx_8h"/> |
---|
35 | <childnode refid="808" relation="include"> |
---|
36 | </childnode> |
---|
37 | <childnode refid="809" relation="include"> |
---|
38 | </childnode> |
---|
39 | <childnode refid="811" relation="include"> |
---|
40 | </childnode> |
---|
41 | </node> |
---|
42 | <node id="809"> |
---|
43 | <label>../stat/libFN.h</label> |
---|
44 | <link refid="libFN_8h-source"/> |
---|
45 | <childnode refid="808" relation="include"> |
---|
46 | </childnode> |
---|
47 | <childnode refid="810" relation="include"> |
---|
48 | </childnode> |
---|
49 | </node> |
---|
50 | <node id="808"> |
---|
51 | <label>itpp/itbase.h</label> |
---|
52 | </node> |
---|
53 | <node id="806"> |
---|
54 | <label>work/git/mixpp/tests/arx_test.cpp</label> |
---|
55 | <link refid="arx_test.cpp"/> |
---|
56 | <childnode refid="807" relation="include"> |
---|
57 | </childnode> |
---|
58 | <childnode refid="811" relation="include"> |
---|
59 | </childnode> |
---|
60 | </node> |
---|
61 | <node id="812"> |
---|
62 | <label>../math/libDC.h</label> |
---|
63 | <link refid="libDC_8h"/> |
---|
64 | <childnode refid="808" relation="include"> |
---|
65 | </childnode> |
---|
66 | </node> |
---|
67 | </incdepgraph> |
---|
68 | <sectiondef kind="func"> |
---|
69 | <memberdef kind="function" id="arx__test_8cpp_1e66f6b31b5ad750f1fe042a706a4e3d4" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> |
---|
70 | <type>int</type> |
---|
71 | <definition>int main</definition> |
---|
72 | <argsstring>()</argsstring> |
---|
73 | <name>main</name> |
---|
74 | <briefdescription> |
---|
75 | </briefdescription> |
---|
76 | <detaileddescription> |
---|
77 | </detaileddescription> |
---|
78 | <inbodydescription> |
---|
79 | </inbodydescription> |
---|
80 | <location file="/home/smidl/work/git/mixpp/tests/arx_test.cpp" line="9" bodyfile="/home/smidl/work/git/mixpp/tests/arx_test.cpp" bodystart="9" bodyend="44"/> |
---|
81 | </memberdef> |
---|
82 | </sectiondef> |
---|
83 | <briefdescription> |
---|
84 | </briefdescription> |
---|
85 | <detaileddescription> |
---|
86 | </detaileddescription> |
---|
87 | <programlisting> |
---|
88 | <codeline lineno="1"><highlight class="preprocessor">#include<sp/><<ref refid="arx_8h" kindref="compound" tooltip="Bayesian Filtering for generalized autoregressive (ARX) model.">estim/arx.h</ref>></highlight><highlight class="normal"></highlight></codeline> |
---|
89 | <codeline lineno="2"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/><<ref refid="libEF_8h" kindref="compound" tooltip="Probability distributions for Exponential Family models.">stat/libEF.h</ref>></highlight><highlight class="normal"></highlight></codeline> |
---|
90 | <codeline lineno="3"><highlight class="normal"></highlight><highlight class="keyword">using<sp/>namespace<sp/></highlight><highlight class="normal">itpp;</highlight></codeline> |
---|
91 | <codeline lineno="4"><highlight class="normal"></highlight></codeline> |
---|
92 | <codeline lineno="5"><highlight class="normal"></highlight><highlight class="comment">//These<sp/>lines<sp/>are<sp/>needed<sp/>for<sp/>use<sp/>of<sp/>cout<sp/>and<sp/>endl</highlight><highlight class="normal"></highlight></codeline> |
---|
93 | <codeline lineno="6"><highlight class="normal"></highlight><highlight class="keyword">using</highlight><highlight class="normal"><sp/>std::cout;</highlight></codeline> |
---|
94 | <codeline lineno="7"><highlight class="normal"></highlight><highlight class="keyword">using</highlight><highlight class="normal"><sp/>std::endl;</highlight></codeline> |
---|
95 | <codeline lineno="8"><highlight class="normal"></highlight></codeline> |
---|
96 | <codeline lineno="9"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><ref refid="sim__var_8cpp_1e66f6b31b5ad750f1fe042a706a4e3d4" kindref="member" tooltip="Extended Kalman filter with unknown Q.">main</ref>()<sp/>{</highlight></codeline> |
---|
97 | <codeline lineno="10"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Setup<sp/>model</highlight><highlight class="normal"></highlight></codeline> |
---|
98 | <codeline lineno="11"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>th(</highlight><highlight class="stringliteral">"0.8<sp/>-0.3<sp/>0.4<sp/>0.01"</highlight><highlight class="normal">);</highlight></codeline> |
---|
99 | <codeline lineno="12"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ord=th.length();</highlight></codeline> |
---|
100 | <codeline lineno="13"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>sqr=1;</highlight></codeline> |
---|
101 | <codeline lineno="14"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline> |
---|
102 | <codeline lineno="15"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//Test<sp/>constructor</highlight><highlight class="normal"></highlight></codeline> |
---|
103 | <codeline lineno="16"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>V0<sp/>=<sp/>0.001*eye(ord+1);<sp/>V0(0.0)*=<sp/>10;<sp/></highlight><highlight class="comment">//</highlight><highlight class="normal"></highlight></codeline> |
---|
104 | <codeline lineno="17"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>nu0<sp/>=<sp/>ord+1;</highlight></codeline> |
---|
105 | <codeline lineno="18"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline> |
---|
106 | <codeline lineno="19"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>thr(</highlight><highlight class="stringliteral">"{theta_and_r<sp/>}"</highlight><highlight class="normal">);</highlight></codeline> |
---|
107 | <codeline lineno="20"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classARX" kindref="compound" tooltip="Linear Autoregressive model with Gaussian noise.">ARX</ref><sp/>Ar(thr,<sp/>V0,<sp/>nu0);</highlight></codeline> |
---|
108 | <codeline lineno="21"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>&<sp/>Ar_ep<sp/>=<sp/>Ar._epdf();</highlight></codeline> |
---|
109 | <codeline lineno="22"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline> |
---|
110 | <codeline lineno="23"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//Test<sp/>estimation</highlight><highlight class="normal"></highlight></codeline> |
---|
111 | <codeline lineno="24"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ndat<sp/>=<sp/>1000;</highlight></codeline> |
---|
112 | <codeline lineno="25"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>t,j;</highlight></codeline> |
---|
113 | <codeline lineno="26"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>Yt(ndat);</highlight></codeline> |
---|
114 | <codeline lineno="27"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>LL(ndat);</highlight></codeline> |
---|
115 | <codeline lineno="28"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Yt.set_subvector(0,randn(ord));<sp/></highlight><highlight class="comment">//initial<sp/>values</highlight><highlight class="normal"></highlight></codeline> |
---|
116 | <codeline lineno="29"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>rgr(ord);</highlight></codeline> |
---|
117 | <codeline lineno="30"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline> |
---|
118 | <codeline lineno="31"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cout<sp/><<<sp/>Ar_ep.<ref refid="classepdf_1bf0a070a8f3e67a93604ca724638b870" kindref="member" tooltip="return expected value">mean</ref>()<<endl;</highlight></codeline> |
---|
119 | <codeline lineno="32"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(t=ord;<sp/>t<ndat;<sp/>t++)<sp/>{</highlight></codeline> |
---|
120 | <codeline lineno="33"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal">(j=0;j<(ord);j++){rgr(j)=Yt(t-j-1);}</highlight></codeline> |
---|
121 | <codeline lineno="34"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Yt(t)<sp/>=<sp/>th*rgr<sp/>+<sp/>sqr<sp/>*<sp/>NorRNG();</highlight></codeline> |
---|
122 | <codeline lineno="35"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline> |
---|
123 | <codeline lineno="36"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>Psi<sp/>=<sp/>concat(Yt(t),<sp/>rgr);</highlight></codeline> |
---|
124 | <codeline lineno="37"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Ar.bayes(Psi);</highlight></codeline> |
---|
125 | <codeline lineno="38"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>LL(t)<sp/>=<sp/>Ar._ll();</highlight></codeline> |
---|
126 | <codeline lineno="39"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
127 | <codeline lineno="40"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cout<sp/><<<sp/>Ar_ep.<ref refid="classepdf_1bf0a070a8f3e67a93604ca724638b870" kindref="member" tooltip="return expected value">mean</ref>()<<endl;</highlight></codeline> |
---|
128 | <codeline lineno="41"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline> |
---|
129 | <codeline lineno="42"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Test<sp/>brute-froce<sp/>structure<sp/>estimation</highlight><highlight class="normal"></highlight></codeline> |
---|
130 | <codeline lineno="43"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cout<sp/><<<sp/>Ar.structure_est(<ref refid="classegiw" kindref="compound" tooltip="Gauss-inverse-Wishart density stored in LD form.">egiw</ref>(thr,V0,nu0))<sp/><<endl;</highlight></codeline> |
---|
131 | <codeline lineno="44"><highlight class="normal">}</highlight></codeline> |
---|
132 | </programlisting> |
---|
133 | <location file="/home/smidl/work/git/mixpp/tests/arx_test.cpp"/> |
---|
134 | </compounddef> |
---|
135 | </doxygen> |
---|