Index: applications/mpdm/TR2244/contour_2.m
===================================================================
--- applications/mpdm/TR2244/contour_2.m (revision 321)
+++ applications/mpdm/TR2244/contour_2.m (revision 321)
@@ -0,0 +1,12 @@
+function contour(x,y,z,str)
+ %
+ xlin=linspace(min(x),max(x),33);
+ ylin=linspace(min(y),max(y),33);
+ [X,Y]=meshgrid(xlin,ylin);
+ Z=griddata(x,y,z,X,Y,'nearest');
+ %
+ if nargin<4
+     contour(X,Y,Z,7)
+ else
+     contour(X,Y,Z,str)
+ end     
Index: applications/mpdm/TR2244/merger_iter_debug3.m
===================================================================
--- applications/mpdm/TR2244/merger_iter_debug3.m (revision 321)
+++ applications/mpdm/TR2244/merger_iter_debug3.m (revision 321)
@@ -0,0 +1,49 @@
+itload('iter_cond_debug3.it');
+
+ndat = 1000; % check if true!
+
+prop_mean=zeros(3,40);
+prop_var=zeros(3,40);
+for it=0:39
+    si = num2str(it);
+    eval(['eff_w(it+1) = 1/(w' si '''*w' si ');']);
+    eval(['prop_mean(1:3,it+1) = Mpred_mean' si ';']);
+    eval(['prop_var(1:3,it+1) = Mpred_var' si '(1:3);']);
+end
+
+figure(2)
+subplot(1,2,1)
+hold off
+plot(eff_w)
+xlabel('iteration');
+title('Effective sample size');
+%title('Non-normalized importance weights')
+
+subplot(1,2,2);
+hold off
+plot(prop_mean');
+hold on
+plot(prop_mean'+2*sqrt(prop_var'),'.');
+plot(prop_mean'-2*sqrt(prop_var'),'.');
+
+%plot(ones(size(prop_mean,2),1)*[3 2],'--')
+xlabel('iteration');
+title('Mean value of the joint merger $\tilde{f}(\bm{x})$');
+
+% itload('../merger_iter_test.it');
+% XG = reshape(Grid(1,:),Npoints,Npoints);
+% YG = reshape(Grid(2,:),Npoints,Npoints);
+% 
+% figure(2);
+% M1 = reshape(exp(Res1),Npoints,Npoints);
+% contour(XG,YG,M1,7);
+% 
+% figure(3);
+% hold off
+% mm = max(max(Res2));
+% for i=1:size(Res2,1)
+%     M2 = reshape(Res2(i,:),Npoints,Npoints);
+%     contour(XG,YG,M2,[0:mm/7:mm]);
+%     hold on
+% end
+
Index: applications/mpdm/SYSID09/merg_egiw.m
===================================================================
--- applications/mpdm/SYSID09/merg_egiw.m (revision 321)
+++ applications/mpdm/SYSID09/merg_egiw.m (revision 321)
@@ -0,0 +1,34 @@
+itload('merg_egiw.it');
+
+figure(1);
+subplot(1,3,1);
+hold off
+plot(G(:,1),'-')
+hold on
+plot(P1(:,1),'+-')
+plot(M(:,1),'--')
+plot([1,100],[1.5,1.5],':')
+xlabel('time [t]')
+title('Expected value of a_1')
+
+subplot(1,3,2);
+hold off
+plot(G(:,2),'-')
+hold on
+plot(P2(:,1),'+-')
+plot(M(:,3),'--')
+plot([1,100],[0.8,0.8],':')
+xlabel('time [t]')
+title('Expected value of a_2')
+
+subplot(1,3,3);
+hold off
+plot(G(:,3))
+hold on
+plot(P1(:,2),'--')
+plot(P2(:,2),'+-')
+plot(M(:,2),'--')
+plot([1,100],[0.01,0.01],':')
+xlabel('time [t]')
+title('Expected value of \sigma')
+
Index: applications/mpdm/SYSID09/merg_2a.m
===================================================================
--- applications/mpdm/SYSID09/merg_2a.m (revision 321)
+++ applications/mpdm/SYSID09/merg_2a.m (revision 321)
@@ -0,0 +1,46 @@
+function merg_2a(fname)
+itload(fname);
+
+Mm=Mm(1:99,:);
+P1m=P1m(1:99,:);
+P2m=P2m(1:99,:);
+T=T(1:99,:);
+
+
+
+figure(1)
+subplot(2,2,1)
+hold off
+plot(T(:,1),':');
+hold on
+plot(Mm(:,1),'--','LineWidth',2);
+plot(P1m(:,1),'--');
+plot(P2m(:,1),'-');
+title('parameter a and its estimates')
+
+subplot(2,2,2);
+hold off
+plot(T(:,2),':');
+hold on
+plot(Mm(:,2),'--','LineWidth',2);
+plot(P1m(:,2),'--');
+title('parameter b and its estimates')
+
+subplot(2,2,3)
+hold off
+plot(T(:,3),':');
+hold on
+plot(Mm(:,4),'--','LineWidth',2);
+plot(P2m(:,2),'-');
+xlabel('time ');
+title('parameter c and its estimates')
+
+subplot(2,2,4)
+hold off
+plot(T(:,4),':');
+hold on
+plot(Mm(:,3),'--','LineWidth',2);
+plot(P1m(:,3),'--');
+plot(P2m(:,3),'-');
+title('parameter \sigma^2 and its estimates')
+xlabel('time ');
Index: applications/mpdm/SYSID09/merger_dbg.m
===================================================================
--- applications/mpdm/SYSID09/merger_dbg.m (revision 321)
+++ applications/mpdm/SYSID09/merger_dbg.m (revision 321)
@@ -0,0 +1,10 @@
+funtion merge_dbg(fname);
+itload(fname);
+
+t=size(T,1);
+
+m1=zeros(t,size(
+for i=1:t
+
+    m1 
+figure(1);
Index: applications/mpdm/SYSID09/plotsmp.m
===================================================================
--- applications/mpdm/SYSID09/plotsmp.m (revision 321)
+++ applications/mpdm/SYSID09/plotsmp.m (revision 321)
@@ -0,0 +1,11 @@
+function plotsmp(Smp,fg)
+nc = size(Smp,2);
+
+figure(fg);
+for i=1:nc
+    for j=1:nc
+        subplot(nc,nc,(i-1)*nc+j);
+        plot(Smp(:,i),Smp(:,j),'.');
+    end
+end
+    
Index: applications/mpdm/SYSID09/merg_2a.kst
===================================================================
--- applications/mpdm/SYSID09/merg_2a.kst (revision 321)
+++ applications/mpdm/SYSID09/merg_2a.kst (revision 321)
@@ -0,0 +1,997 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kstdoc version="1.3">
+  <windowsize>
+    <width>1440</width>
+    <height>854</height>
+    <active name="W1"/>
+  </windowsize>
+  <graphicsautosave time="1" enabled="false" format="EPS" xsize="600" ysize="480" display="2" square="false" />
+  <kstfile>
+    <tag>DS-merg_2a</tag>
+    <filename>/home/smidl/work/git/mixpp/applications/mpdm/SYSID09/exp/merg_2a/</filename>
+    <type>Directory of Binary Files</type>
+  </kstfile>
+  <scalar>
+    <tag>P1/XMin</tag>
+    <orphan/>
+    <value>0</value>
+  </scalar>
+  <scalar>
+    <tag>P1/XMax</tag>
+    <orphan/>
+    <value>96</value>
+  </scalar>
+  <scalar>
+    <tag>P1/YMin</tag>
+    <orphan/>
+    <value>0.46426470018143</value>
+  </scalar>
+  <scalar>
+    <tag>P1/YMax</tag>
+    <orphan/>
+    <value>2.1186083022493</value>
+  </scalar>
+  <scalar>
+    <tag>P2/XMin</tag>
+    <orphan/>
+    <value>0</value>
+  </scalar>
+  <scalar>
+    <tag>P2/XMax</tag>
+    <orphan/>
+    <value>96</value>
+  </scalar>
+  <scalar>
+    <tag>P2/YMin</tag>
+    <orphan/>
+    <value>-1.5880839007662</value>
+  </scalar>
+  <scalar>
+    <tag>P2/YMax</tag>
+    <orphan/>
+    <value>4.1938191206759</value>
+  </scalar>
+  <scalar>
+    <tag>P3/XMin</tag>
+    <orphan/>
+    <value>0</value>
+  </scalar>
+  <scalar>
+    <tag>P3/XMax</tag>
+    <orphan/>
+    <value>96</value>
+  </scalar>
+  <scalar>
+    <tag>P3/YMin</tag>
+    <orphan/>
+    <value>-0.64874492120258</value>
+  </scalar>
+  <scalar>
+    <tag>P3/YMax</tag>
+    <orphan/>
+    <value>0.36497939439052</value>
+  </scalar>
+  <scalar>
+    <tag>P4/XMin</tag>
+    <orphan/>
+    <value>0</value>
+  </scalar>
+  <scalar>
+    <tag>P4/XMax</tag>
+    <orphan/>
+    <value>96</value>
+  </scalar>
+  <scalar>
+    <tag>P4/YMin</tag>
+    <orphan/>
+    <value>0.071465383493815</value>
+  </scalar>
+  <scalar>
+    <tag>P4/YMax</tag>
+    <orphan/>
+    <value>0.16292658384588</value>
+  </scalar>
+  <vector>
+    <tag>DS-merg_2a/INDEX</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>INDEX</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/T_a</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>T_a</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/T_b</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>T_b</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/T_c</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>T_c</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/T_r</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>T_r</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/Mm_a</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>Mm_a</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/Mm_b</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>Mm_b</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/Mm_c</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>Mm_c</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/Mm_r</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>Mm_r</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/P1m_a</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>P1m_a</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/P1m_b</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>P1m_b</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/P1m_r</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>P1m_r</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/P2m_a</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>P2m_a</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/P2m_c</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>P2m_c</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <vector>
+    <tag>DS-merg_2a/P2m_r</tag>
+    <provider>DS-merg_2a</provider>
+    <filename>/home/smidl/work/git/mixpp/mpdm/SYSID09/exp/merg_2a/</filename>
+    <field>P2m_r</field>
+    <start>-1</start>
+    <num>89996</num>
+  </vector>
+  <curve>
+    <tag>T_a</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/T_a</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#000000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>1</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>T_b</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/T_b</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#000000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>1</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>T_c</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/T_c</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#000000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>1</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>T_r</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/T_r</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#000000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>1</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>Mm_a</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/Mm_a</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#0000ff</color>
+    <hasLines/>
+    <lineWidth>2</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>Mm_b</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/Mm_b</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#0000ff</color>
+    <hasLines/>
+    <lineWidth>2</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>Mm_c</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/Mm_c</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#0000ff</color>
+    <hasLines/>
+    <lineWidth>2</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>Mm_r</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/Mm_r</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#0000ff</color>
+    <hasLines/>
+    <lineWidth>2</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>P1m_a</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/P1m_a</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#008000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>P1m_b</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/P1m_b</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#008000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>P1m_r</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/P1m_r</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#008000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>P2m_a</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/P2m_a</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#ff0000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>P2m_c</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/P2m_c</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#ff0000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <curve>
+    <tag>P2m_r</tag>
+    <xvectag>DS-merg_2a/INDEX</xvectag>
+    <yvectag>DS-merg_2a/P2m_r</yvectag>
+    <legend></legend>
+    <interp>0</interp>
+    <hasMinus/>
+    <color>#ff0000</color>
+    <hasLines/>
+    <lineWidth>0</lineWidth>
+    <lineStyle>0</lineStyle>
+    <pointType>0</pointType>
+    <pointDensity>0</pointDensity>
+    <barStyle>0</barStyle>
+  </curve>
+  <plot>
+    <border color="#000000" width="0" padding="0" margin="0" />
+    <tag>P1</tag>
+    <aspect x="0" y="0" w="0.5" h="0.5" />
+    <idealsize w="504" h="278" />
+    <name>P1</name>
+    <borderColor>#000000</borderColor>
+    <borderWidth>0</borderWidth>
+    <foregroundColor>#000000</foregroundColor>
+    <backgroundColor>#ffffff</backgroundColor>
+    <margin>0</margin>
+    <padding>0</padding>
+    <xscalemode>0</xscalemode>
+    <yscalemode>6</yscalemode>
+    <xscalemodedefault>0</xscalemodedefault>
+    <yscalemodedefault>5</yscalemodedefault>
+    <xmin>0</xmin>
+    <xmax>96</xmax>
+    <ymin>0.46426470018143</ymin>
+    <ymax>2.1186083022493</ymax>
+    <xreversed>0</xreversed>
+    <yreversed>0</yreversed>
+    <yminexp>0.46426470018143</yminexp>
+    <ymaxexp>2.1186083022493</ymaxexp>
+    <toplabel>
+      <text></text>
+      <interpret/>
+      <rotation>0</rotation>
+      <justify>1</justify>
+      <fontfamily>DejaVu Sans</fontfamily>
+      <size>11</size>
+    </toplabel>
+    <xlabel>
+      <text> time t</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily>DejaVu Sans</fontfamily>
+      <size>11</size>
+    </xlabel>
+    <ylabel>
+      <text>parameter a</text>
+      <interpret/>
+      <rotation>270</rotation>
+      <fontfamily>DejaVu Sans</fontfamily>
+      <size>11</size>
+    </ylabel>
+    <xticklabel>
+      <text>80</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </xticklabel>
+    <yticklabel>
+      <text>2</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </yticklabel>
+    <xfullticklabel>
+      <text></text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </xfullticklabel>
+    <xlogbase>10</xlogbase>
+    <ylogbase>10</ylogbase>
+    <curvetag>T_a</curvetag>
+    <curvetag>Mm_a</curvetag>
+    <curvetag>P1m_a</curvetag>
+    <curvetag>P2m_a</curvetag>
+    <xmajorgrid>0</xmajorgrid>
+    <ymajorgrid>0</ymajorgrid>
+    <xminorgrid>0</xminorgrid>
+    <yminorgrid>0</yminorgrid>
+    <majorgridcolor>#808080</majorgridcolor>
+    <minorgridcolor>#808080</minorgridcolor>
+    <majorgridcolordefault>1</majorgridcolordefault>
+    <minorgridcolordefault>1</minorgridcolordefault>
+    <majorpenwidth>1</majorpenwidth>
+    <minorpenwidth>1</minorpenwidth>
+    <axispenwidth>1</axispenwidth>
+    <xminorticks>-1</xminorticks>
+    <yminorticks>-1</yminorticks>
+    <xmajorticks>5</xmajorticks>
+    <ymajorticks>5</ymajorticks>
+    <xticksinplot>1</xticksinplot>
+    <xticksoutplot>0</xticksoutplot>
+    <yticksinplot>1</yticksinplot>
+    <yticksoutplot>0</yticksoutplot>
+    <suppresstop>0</suppresstop>
+    <suppressbottom>0</suppressbottom>
+    <suppressleft>0</suppressleft>
+    <suppressright>0</suppressright>
+    <xtransformed>0</xtransformed>
+    <ytransformed>0</ytransformed>
+    <xtransformedexp></xtransformedexp>
+    <ytransformedexp></ytransformedexp>
+    <xinterpret>0</xinterpret>
+    <xinterpretas>1</xinterpretas>
+    <xdisplayas>4</xdisplayas>
+    <yinterpret>0</yinterpret>
+    <yinterpretas>1</yinterpretas>
+    <ydisplayas>4</ydisplayas>
+    <xoffsetmode>0</xoffsetmode>
+    <yoffsetmode>0</yoffsetmode>
+    <stylemarker>0</stylemarker>
+    <widthmarker>0</widthmarker>
+    <colormarker>#000000</colormarker>
+    <defaultcolormarker>1</defaultcolormarker>
+    <autoLabelTop>1</autoLabelTop>
+    <autoLabelX>0</autoLabelX>
+    <autoLabelY>0</autoLabelY>
+  </plot>
+  <plot>
+    <border color="#000000" width="0" padding="0" margin="0" />
+    <tag>P2</tag>
+    <aspect x="0.5" y="0" w="0.5" h="0.5" />
+    <idealsize w="504" h="278" />
+    <name>P2</name>
+    <borderColor>#000000</borderColor>
+    <borderWidth>0</borderWidth>
+    <foregroundColor>#000000</foregroundColor>
+    <backgroundColor>#ffffff</backgroundColor>
+    <margin>0</margin>
+    <padding>0</padding>
+    <xscalemode>0</xscalemode>
+    <yscalemode>2</yscalemode>
+    <xscalemodedefault>0</xscalemodedefault>
+    <yscalemodedefault>5</yscalemodedefault>
+    <xmin>0</xmin>
+    <xmax>96</xmax>
+    <ymin>-1.5880839007662</ymin>
+    <ymax>4.1938191206759</ymax>
+    <xreversed>0</xreversed>
+    <yreversed>0</yreversed>
+    <toplabel>
+      <text></text>
+      <interpret/>
+      <rotation>0</rotation>
+      <justify>0</justify>
+      <fontfamily>DejaVu Sans [unknown]</fontfamily>
+      <size>11</size>
+    </toplabel>
+    <xlabel>
+      <text> time t</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily>DejaVu Sans [unknown]</fontfamily>
+      <size>11</size>
+    </xlabel>
+    <ylabel>
+      <text> parametr b</text>
+      <interpret/>
+      <rotation>270</rotation>
+      <fontfamily>DejaVu Sans [unknown]</fontfamily>
+      <size>11</size>
+    </ylabel>
+    <xticklabel>
+      <text>80</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </xticklabel>
+    <yticklabel>
+      <text>4</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </yticklabel>
+    <xfullticklabel>
+      <text></text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </xfullticklabel>
+    <xlogbase>10</xlogbase>
+    <ylogbase>10</ylogbase>
+    <curvetag>T_b</curvetag>
+    <curvetag>Mm_b</curvetag>
+    <curvetag>P1m_b</curvetag>
+    <xmajorgrid>0</xmajorgrid>
+    <ymajorgrid>0</ymajorgrid>
+    <xminorgrid>0</xminorgrid>
+    <yminorgrid>0</yminorgrid>
+    <majorgridcolor>#808080</majorgridcolor>
+    <minorgridcolor>#808080</minorgridcolor>
+    <majorgridcolordefault>1</majorgridcolordefault>
+    <minorgridcolordefault>1</minorgridcolordefault>
+    <majorpenwidth>1</majorpenwidth>
+    <minorpenwidth>1</minorpenwidth>
+    <axispenwidth>1</axispenwidth>
+    <xminorticks>-1</xminorticks>
+    <yminorticks>-1</yminorticks>
+    <xmajorticks>5</xmajorticks>
+    <ymajorticks>5</ymajorticks>
+    <xticksinplot>1</xticksinplot>
+    <xticksoutplot>0</xticksoutplot>
+    <yticksinplot>1</yticksinplot>
+    <yticksoutplot>0</yticksoutplot>
+    <suppresstop>0</suppresstop>
+    <suppressbottom>0</suppressbottom>
+    <suppressleft>0</suppressleft>
+    <suppressright>0</suppressright>
+    <xtransformed>0</xtransformed>
+    <ytransformed>0</ytransformed>
+    <xtransformedexp></xtransformedexp>
+    <ytransformedexp></ytransformedexp>
+    <xinterpret>0</xinterpret>
+    <xinterpretas>1</xinterpretas>
+    <xdisplayas>4</xdisplayas>
+    <yinterpret>0</yinterpret>
+    <yinterpretas>1</yinterpretas>
+    <ydisplayas>4</ydisplayas>
+    <xoffsetmode>0</xoffsetmode>
+    <yoffsetmode>0</yoffsetmode>
+    <stylemarker>0</stylemarker>
+    <widthmarker>0</widthmarker>
+    <colormarker>#000000</colormarker>
+    <defaultcolormarker>1</defaultcolormarker>
+    <autoLabelTop>1</autoLabelTop>
+    <autoLabelX>0</autoLabelX>
+    <autoLabelY>0</autoLabelY>
+  </plot>
+  <plot>
+    <border color="#000000" width="0" padding="0" margin="0" />
+    <tag>P3</tag>
+    <aspect x="0" y="0.5" w="0.5" h="0.5" />
+    <idealsize w="504" h="278" />
+    <name>P3</name>
+    <borderColor>#000000</borderColor>
+    <borderWidth>0</borderWidth>
+    <foregroundColor>#000000</foregroundColor>
+    <backgroundColor>#ffffff</backgroundColor>
+    <margin>0</margin>
+    <padding>0</padding>
+    <xscalemode>0</xscalemode>
+    <yscalemode>2</yscalemode>
+    <xscalemodedefault>0</xscalemodedefault>
+    <yscalemodedefault>5</yscalemodedefault>
+    <xmin>0</xmin>
+    <xmax>96</xmax>
+    <ymin>-0.64874492120258</ymin>
+    <ymax>0.36497939439052</ymax>
+    <xreversed>0</xreversed>
+    <yreversed>0</yreversed>
+    <toplabel>
+      <text></text>
+      <interpret/>
+      <rotation>0</rotation>
+      <justify>1</justify>
+      <fontfamily>DejaVu Sans</fontfamily>
+      <size>11</size>
+    </toplabel>
+    <xlabel>
+      <text> time t</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily>DejaVu Sans</fontfamily>
+      <size>11</size>
+    </xlabel>
+    <ylabel>
+      <text> parametr c</text>
+      <interpret/>
+      <rotation>270</rotation>
+      <fontfamily>DejaVu Sans</fontfamily>
+      <size>11</size>
+    </ylabel>
+    <xticklabel>
+      <text>80</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </xticklabel>
+    <yticklabel>
+      <text>0.2</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </yticklabel>
+    <xfullticklabel>
+      <text></text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </xfullticklabel>
+    <xlogbase>10</xlogbase>
+    <ylogbase>10</ylogbase>
+    <curvetag>T_c</curvetag>
+    <curvetag>Mm_c</curvetag>
+    <curvetag>P2m_c</curvetag>
+    <xmajorgrid>0</xmajorgrid>
+    <ymajorgrid>0</ymajorgrid>
+    <xminorgrid>0</xminorgrid>
+    <yminorgrid>0</yminorgrid>
+    <majorgridcolor>#808080</majorgridcolor>
+    <minorgridcolor>#808080</minorgridcolor>
+    <majorgridcolordefault>1</majorgridcolordefault>
+    <minorgridcolordefault>1</minorgridcolordefault>
+    <majorpenwidth>1</majorpenwidth>
+    <minorpenwidth>1</minorpenwidth>
+    <axispenwidth>1</axispenwidth>
+    <xminorticks>-1</xminorticks>
+    <yminorticks>-1</yminorticks>
+    <xmajorticks>5</xmajorticks>
+    <ymajorticks>5</ymajorticks>
+    <xticksinplot>1</xticksinplot>
+    <xticksoutplot>0</xticksoutplot>
+    <yticksinplot>1</yticksinplot>
+    <yticksoutplot>0</yticksoutplot>
+    <suppresstop>0</suppresstop>
+    <suppressbottom>0</suppressbottom>
+    <suppressleft>0</suppressleft>
+    <suppressright>0</suppressright>
+    <xtransformed>0</xtransformed>
+    <ytransformed>0</ytransformed>
+    <xtransformedexp></xtransformedexp>
+    <ytransformedexp></ytransformedexp>
+    <xinterpret>0</xinterpret>
+    <xinterpretas>1</xinterpretas>
+    <xdisplayas>4</xdisplayas>
+    <yinterpret>0</yinterpret>
+    <yinterpretas>1</yinterpretas>
+    <ydisplayas>4</ydisplayas>
+    <xoffsetmode>0</xoffsetmode>
+    <yoffsetmode>0</yoffsetmode>
+    <stylemarker>0</stylemarker>
+    <widthmarker>0</widthmarker>
+    <colormarker>#000000</colormarker>
+    <defaultcolormarker>1</defaultcolormarker>
+    <autoLabelTop>1</autoLabelTop>
+    <autoLabelX>0</autoLabelX>
+    <autoLabelY>0</autoLabelY>
+  </plot>
+  <plot>
+    <border color="#000000" width="0" padding="0" margin="0" />
+    <tag>P4</tag>
+    <aspect x="0.5" y="0.5" w="0.5" h="0.5" />
+    <idealsize w="504" h="278" />
+    <name>P4</name>
+    <borderColor>#000000</borderColor>
+    <borderWidth>0</borderWidth>
+    <foregroundColor>#000000</foregroundColor>
+    <backgroundColor>#ffffff</backgroundColor>
+    <margin>0</margin>
+    <padding>0</padding>
+    <xscalemode>0</xscalemode>
+    <yscalemode>2</yscalemode>
+    <xscalemodedefault>0</xscalemodedefault>
+    <yscalemodedefault>5</yscalemodedefault>
+    <xmin>0</xmin>
+    <xmax>96</xmax>
+    <ymin>0.071465383493815</ymin>
+    <ymax>0.16292658384588</ymax>
+    <xreversed>0</xreversed>
+    <yreversed>0</yreversed>
+    <toplabel>
+      <text></text>
+      <interpret/>
+      <rotation>0</rotation>
+      <justify>1</justify>
+      <fontfamily>DejaVu Sans</fontfamily>
+      <size>11</size>
+    </toplabel>
+    <xlabel>
+      <text> time t</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily>DejaVu Sans</fontfamily>
+      <size>11</size>
+    </xlabel>
+    <ylabel>
+      <text> parametr r</text>
+      <interpret/>
+      <rotation>270</rotation>
+      <fontfamily>DejaVu Sans</fontfamily>
+      <size>11</size>
+    </ylabel>
+    <xticklabel>
+      <text>80</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </xticklabel>
+    <yticklabel>
+      <text>0.16</text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </yticklabel>
+    <xfullticklabel>
+      <text></text>
+      <interpret/>
+      <rotation>0</rotation>
+      <fontfamily> </fontfamily>
+      <size>11</size>
+    </xfullticklabel>
+    <xlogbase>10</xlogbase>
+    <ylogbase>10</ylogbase>
+    <curvetag>T_r</curvetag>
+    <curvetag>Mm_r</curvetag>
+    <curvetag>P1m_r</curvetag>
+    <curvetag>P2m_r</curvetag>
+    <xmajorgrid>0</xmajorgrid>
+    <ymajorgrid>0</ymajorgrid>
+    <xminorgrid>0</xminorgrid>
+    <yminorgrid>0</yminorgrid>
+    <majorgridcolor>#808080</majorgridcolor>
+    <minorgridcolor>#808080</minorgridcolor>
+    <majorgridcolordefault>1</majorgridcolordefault>
+    <minorgridcolordefault>1</minorgridcolordefault>
+    <majorpenwidth>1</majorpenwidth>
+    <minorpenwidth>1</minorpenwidth>
+    <axispenwidth>1</axispenwidth>
+    <xminorticks>-1</xminorticks>
+    <yminorticks>-1</yminorticks>
+    <xmajorticks>5</xmajorticks>
+    <ymajorticks>5</ymajorticks>
+    <xticksinplot>1</xticksinplot>
+    <xticksoutplot>0</xticksoutplot>
+    <yticksinplot>1</yticksinplot>
+    <yticksoutplot>0</yticksoutplot>
+    <suppresstop>0</suppresstop>
+    <suppressbottom>0</suppressbottom>
+    <suppressleft>0</suppressleft>
+    <suppressright>0</suppressright>
+    <xtransformed>0</xtransformed>
+    <ytransformed>0</ytransformed>
+    <xtransformedexp></xtransformedexp>
+    <ytransformedexp></ytransformedexp>
+    <xinterpret>0</xinterpret>
+    <xinterpretas>1</xinterpretas>
+    <xdisplayas>4</xdisplayas>
+    <yinterpret>0</yinterpret>
+    <yinterpretas>1</yinterpretas>
+    <ydisplayas>4</ydisplayas>
+    <xoffsetmode>0</xoffsetmode>
+    <yoffsetmode>0</yoffsetmode>
+    <stylemarker>0</stylemarker>
+    <widthmarker>0</widthmarker>
+    <colormarker>#000000</colormarker>
+    <defaultcolormarker>1</defaultcolormarker>
+    <autoLabelTop>1</autoLabelTop>
+    <autoLabelX>0</autoLabelX>
+    <autoLabelY>0</autoLabelY>
+  </plot>
+  <window>
+    <tag>W1</tag>
+    <restore x="2" y="2" w="1436" h="763" />
+    <internal x="2" y="2" w="1436" h="763" />
+    <name>W1</name>
+    <backgroundColor>#efefef</backgroundColor>
+    <Plot>
+      <tag>P1</tag>
+      <Legend>
+        <border color="#000000" width="2" padding="0" margin="0" />
+        <border color="#000000" width="2" padding="0" margin="0" />
+        <tag>Object 194</tag>
+        <aspect x="0.71448467966574" y="0.075916230366492" w="0.2" h="0.1" />
+        <idealsize w="1" h="1" />
+        <name>unnamed</name>
+        <borderColor>#000000</borderColor>
+        <borderWidth>2</borderWidth>
+        <foregroundColor>#000000</foregroundColor>
+        <backgroundColor>#ffffff</backgroundColor>
+        <margin>0</margin>
+        <padding>0</padding>
+        <font></font>
+        <fontSize>11</fontSize>
+        <transparent>false</transparent>
+        <trackContents>true</trackContents>
+        <legendMargin>5</legendMargin>
+        <vertical>true</vertical>
+        <title></title>
+        <curvetag>T_a</curvetag>
+        <curvetag>Mm_a</curvetag>
+        <curvetag>P1m_a</curvetag>
+        <curvetag>P2m_a</curvetag>
+      </Legend>
+    </Plot>
+    <Plot>
+      <tag>P2</tag>
+      <Legend>
+        <border color="#000000" width="2" padding="0" margin="0" />
+        <border color="#000000" width="2" padding="0" margin="0" />
+        <tag>Object 195</tag>
+        <aspect x="0.71866295264624" y="0.1020942408377" w="0.2" h="0.1" />
+        <idealsize w="1" h="1" />
+        <name>unnamed</name>
+        <borderColor>#000000</borderColor>
+        <borderWidth>2</borderWidth>
+        <foregroundColor>#000000</foregroundColor>
+        <backgroundColor>#ffffff</backgroundColor>
+        <margin>0</margin>
+        <padding>0</padding>
+        <font></font>
+        <fontSize>11</fontSize>
+        <transparent>false</transparent>
+        <trackContents>true</trackContents>
+        <legendMargin>5</legendMargin>
+        <vertical>true</vertical>
+        <title></title>
+        <curvetag>T_b</curvetag>
+        <curvetag>Mm_b</curvetag>
+        <curvetag>P1m_b</curvetag>
+      </Legend>
+    </Plot>
+    <Plot>
+      <tag>P3</tag>
+      <Legend>
+        <border color="#000000" width="2" padding="0" margin="0" />
+        <border color="#000000" width="2" padding="0" margin="0" />
+        <tag>Object 196</tag>
+        <aspect x="0.7033426183844" y="0.1259842519685" w="0.2" h="0.1" />
+        <idealsize w="1" h="1" />
+        <name>unnamed</name>
+        <borderColor>#000000</borderColor>
+        <borderWidth>2</borderWidth>
+        <foregroundColor>#000000</foregroundColor>
+        <backgroundColor>#ffffff</backgroundColor>
+        <margin>0</margin>
+        <padding>0</padding>
+        <font></font>
+        <fontSize>11</fontSize>
+        <transparent>false</transparent>
+        <trackContents>true</trackContents>
+        <legendMargin>5</legendMargin>
+        <vertical>true</vertical>
+        <title></title>
+        <curvetag>T_c</curvetag>
+        <curvetag>Mm_c</curvetag>
+        <curvetag>P2m_c</curvetag>
+      </Legend>
+    </Plot>
+    <Plot>
+      <tag>P4</tag>
+      <Legend>
+        <border color="#000000" width="2" padding="0" margin="0" />
+        <border color="#000000" width="2" padding="0" margin="0" />
+        <tag>Object 197</tag>
+        <aspect x="0.70891364902507" y="0.11548556430446" w="0.2" h="0.1" />
+        <idealsize w="1" h="1" />
+        <name>unnamed</name>
+        <borderColor>#000000</borderColor>
+        <borderWidth>2</borderWidth>
+        <foregroundColor>#000000</foregroundColor>
+        <backgroundColor>#ffffff</backgroundColor>
+        <margin>0</margin>
+        <padding>0</padding>
+        <font></font>
+        <fontSize>11</fontSize>
+        <transparent>false</transparent>
+        <trackContents>true</trackContents>
+        <legendMargin>5</legendMargin>
+        <vertical>true</vertical>
+        <title></title>
+        <curvetag>T_r</curvetag>
+        <curvetag>Mm_r</curvetag>
+        <curvetag>P1m_r</curvetag>
+        <curvetag>P2m_r</curvetag>
+      </Legend>
+    </Plot>
+  </window>
+</kstdoc>
Index: applications/mpdm/SYSID09/merg_2a.cpp
===================================================================
--- applications/mpdm/SYSID09/merg_2a.cpp (revision 297)
+++ applications/mpdm/SYSID09/merg_2a.cpp (revision 321)
@@ -47,8 +47,8 @@
 	RV r ("{r }");
 	
-	double at = 1.5;
-	double bt = 0.5;
+	double at = 0.9;
+	double bt = 5;
 	double ct = -0.5;
-	double rt = 0.30;
+	double rt = 0.50;
 	// Full system
 	vec thy =vec_2 ( at,bt ); //Simulated system - zero for constant term
@@ -58,10 +58,12 @@
 
 	//ARX constructor
-	mat V0 = 0.001*eye ( 3 ); V0 ( 0,0 ) = 1; //
+	mat V0 = 0.01*eye ( 3 ); V0 ( 0,0 ) = 1; //
 
 	ARX P1; P1.set_rv(concat(ab,r));
 	P1.set_statistics(1, V0, -1 );
+	P1.set_parameters(0.9);
 	ARX P2; P2.set_rv(concat(ac,r));
-	 P2.set_statistics(1, V0, -1 );
+	P2.set_statistics(1, V0, -1 );
+	P2.set_parameters(0.9);
 
 	//Test estimation
@@ -70,5 +72,5 @@
 
 	// Logging
-	dirfilelog L ( "exp/merg_2a",3 );
+	dirfilelog L ( "exp/merg_2a",100 );
 	int Li_Data = L.add ( RV ( "{U Y Z }" ), "" );
 //	int Li_LL   = L.add ( RV ( "{P1 P2 M1 M2 }" ), "LL" );
@@ -90,25 +92,34 @@
 	g1.set_parameters ( "2  ", "2" );
 	enorm<ldmat> g2; g2.set_rv(c); 
-	g2.set_parameters ( "1 ",mat ( "1" ) );
+	g2.set_parameters ( "-1 ",mat ( "1" ) );
 
 	Array<const epdf*> A ( 3 ); A ( 0 ) = &g0; A ( 1 ) =&g1; A(2) = &g2; 
 	eprod G0; G0.set_parameters ( A );
 
-	vec rgru(2);
+	epdf* proposal=&G0;
+	
 	vec rgry(2);
+	vec rgrz(2);
 	Yt(0) = 0.1;
 	Ut(0) = 0.0;
 	for ( t=1; t<ndat; t++ ) {
 		// True system
-		Ut ( t ) = pow ( sin ( ( t/40.0 ) *pi ),3 );
-		rgru(0) = Ut(t); rgru(1) = Ut(t-1);
-		Yt ( t ) = thy*rgru + rt * NorRNG();
-		rgry(0) = Yt(t); rgry(1) = Yt(t-1);
-		Zt ( t ) = thz*rgry + rt * NorRNG();
+		Ut ( t ) = 0.1*pow ( sin ( ( t/40.0 ) *pi ),3 );
+		
+		rgry(0) = Ut(t); rgry(1) = Ut(t-1);
+		Yt ( t ) = thy*rgry + rt * NorRNG();
+		
+		rgrz(0) = Yt(t); rgrz(1) = Yt(t-1);
+		Zt ( t ) = thz*rgrz + rt * NorRNG();
 
 		// Bayes for all
-		P1.bayes ( concat ( Yt ( t ),rgru ) );
-		P2.bayes ( concat ( Zt ( t ),rgry ) );
+		P1.bayes ( concat ( Yt ( t ),rgry ) );
+		P2.bayes ( concat ( Zt ( t ),rgrz ) );
 
+		if (t>50) {bt+=0.1;
+			thy(1)=bt;}
+		if (t>50) {ct-=0.01;
+			thz(1)=ct;}
+		
 		// Merge estimates
 		mepdf eG1 ( P1._e() );
@@ -116,8 +127,12 @@
 		Array<mpdf*> A ( 2 ); A ( 0 ) =&eG1;A ( 1 ) =&eG2;
 		merger M ( A );
-		M.set_parameters ( 10, 100,3 ); //M._Mix().set_method(QB);
+		M.set_parameters ( 2, 100,20 ,0.99); M._Mix().set_method(QB);
 		//M2.set_parameters ( 100.0, 1000,3 ); //M2._Mix().set_method(QB);
-		M.merge ( &G0 );
+/*		char fnm[100];
+		sprintf(fnm,"m2a_dbg%d.it",t);
+		M.debug_file(fnm);*/
+		M.merge ( proposal );
 
+		//proposal = M.proposal();
 		//Likelihood
 		yt ( 0 ) = Yt ( t );
@@ -131,4 +146,5 @@
 		L.step ( );
 
+		cout << t << "," << endl;
 	}
 	L.finalize( );
