Index: applications/bdmtoolbox/Doxyfile
===================================================================
--- applications/bdmtoolbox/Doxyfile (revision 613)
+++ applications/bdmtoolbox/Doxyfile (revision 744)
@@ -26,5 +26,5 @@
 INLINE_INHERITED_MEMB  = YES
 FULL_PATH_NAMES        = NO
-STRIP_FROM_PATH        = /home/smidl/
+STRIP_FROM_PATH        = /home/smidl/work/git/mixpp
 STRIP_FROM_INC_PATH    = 
 SHORT_NAMES            = NO
@@ -246,5 +246,5 @@
 # configuration options related to the XML output
 #---------------------------------------------------------------------------
-GENERATE_XML           = yes
+GENERATE_XML           = NO
 XML_OUTPUT             = xml
 XML_SCHEMA             = 
Index: applications/bdmtoolbox/tutorial/merging/merge_frag.m
===================================================================
--- applications/bdmtoolbox/tutorial/merging/merge_frag.m (revision 706)
+++ applications/bdmtoolbox/tutorial/merging/merge_frag.m (revision 744)
@@ -16,5 +16,5 @@
 Merger.ncoms=20;
 Merger.stop_niter=50;
-Merger.effss_coef=1;
+Merger.effss_coef=0.9;
 %Merger.dbg_file='merger_mix_dbg';
 
@@ -32,6 +32,7 @@
     'R',1);
 % 2D support
-support2.grid={[-5,5],[0.001,9]};
-support2.nbins=[30,30];
+support2.class='rectangular_support';
+support2.ranges={[-5,5],[0.001,9]};
+support2.gridsizes=[30,30];
 
 % 2D
Index: applications/bdmtoolbox/tutorial/userguide/arx_ctrl_example.m
===================================================================
--- applications/bdmtoolbox/tutorial/userguide/arx_ctrl_example.m (revision 724)
+++ applications/bdmtoolbox/tutorial/userguide/arx_ctrl_example.m (revision 744)
@@ -1,11 +1,12 @@
 % name random variables
 y = RV({'y'},1);
-u = RV({'u'},1);
+u1 = RV({'u1'},1);
+u2 = RV({'u2'},1);
 
 % create f(y_t| y_{t-3}, u_{t-1})
 fy.class = 'mlnorm<ldmat>';
 fy.rv    = y;
-fy.rvc   = RVtimes([y,u], [-3, -1]);
-fy.A     = [0.5, -0.9];
+fy.rvc   = RVtimes([y,u1,u2], [-3, 0, 0]);
+fy.A     = [0.5, -0.9, 0.9];
 fy.const = 0;
 fy.R     = 1e-2;
@@ -17,13 +18,16 @@
 A1.class = 'ARX';
 A1.rv = y;
-A1.rgr = RVtimes([y,u],[-3,-1]) ; % correct structure is {y,y}
+A1.rgr = RVtimes([y,u1,u2],[-3,0,0]) ; % correct structure is {y,y}
 A1.options ='logbounds,logll';
 
 C1.class = 'LQG_ARX';
 C1.ARX = A1;
-C1.Qu = 0.1*eye(1);
+C1.Qu = 0.1*eye(2);
 C1.Qy = eye(1);
 C1.yreq = 1;
 C1.horizon = 100;
 
+% participant 1
+Cp1.
+
 M= controlloop(DS,{C1});
Index: applications/bdmtoolbox/tutorial/userguide/dist_ctrl_example.m
===================================================================
--- applications/bdmtoolbox/tutorial/userguide/dist_ctrl_example.m (revision 744)
+++ applications/bdmtoolbox/tutorial/userguide/dist_ctrl_example.m (revision 744)
@@ -0,0 +1,66 @@
+% name random variables
+y = RV({'y'},1);
+u1 = RV({'u1'},1);
+u2 = RV({'u2'},1);
+
+% create f(y_t| y_{t-3}, u_{t-1})
+fy.class = 'mlnorm<ldmat>';
+fy.rv    = y;
+fy.rvc   = RVtimes([y,u1,u2], [-3, 0, 0]);
+fy.A     = [0.5, -0.9, 0.9];
+fy.const = 0;
+fy.R     = 1e-2;
+
+DS.class = 'PdfDS';
+DS.pdf = fy;
+
+% create ARX estimator
+A1.class = 'ARX';
+A1.rv = y;
+A1.rgr = RVtimes([y,u1],[-3,0]) ; % correct structure is {y,y}
+A1.options ='logbounds,logll';
+A1.frg = 0.95;
+
+A2=A1;
+A2.rgr = RVtimes([y,u2],[-3,0]) ; % correct structure is {y,y}
+
+
+C1.class = 'LQG_ARX';
+C1.ARX = A1;
+C1.Qu = 0.1*eye(1);
+C1.Qy = 1*eye(1);
+C1.yreq = 1;
+C1.horizon = 100;
+
+C2=C1;
+C2.ARX = A2;
+
+M= controlloop(DS,{C1,C2});
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%       PLOTS
+
+figure(1);
+hold off
+subplot(1,2,1);
+plot(M.DS_y);
+subplot(1,2,2);
+plot(M.DS_u1); hold on;
+plot(M.DS_u2); 
+
+figure(2);
+hold off
+plot(M.Ctrl0_apost_mean_theta);
+hold on
+plot(M.Ctrl0_apost_ub_theta,':');
+plot(M.Ctrl0_apost_lb_theta,':');
+set(gca,'YLim',[-4,2]);
+
+figure(3);
+hold off
+plot(M.Ctrl1_apost_mean_theta);
+hold on
+plot(M.Ctrl1_apost_ub_theta,':');
+plot(M.Ctrl1_apost_lb_theta,':');
+set(gca,'YLim',[-2,3]);
Index: applications/bdmtoolbox/mex/controlloop.cpp
===================================================================
--- applications/bdmtoolbox/mex/controlloop.cpp (revision 723)
+++ applications/bdmtoolbox/mex/controlloop.cpp (revision 744)
@@ -7,7 +7,10 @@
 digraph estimation{
 	node [shape=box];
-	{rank="same"; "Data Source"; "Bayesian Model"}
-	"Data Source" -> "Bayesian Model" [label="data"];
-	"Bayesian Model" -> "Result Logger" [label="estimated\n statistics"];
+	subgraph cl0 {
+	"Data Source" -> "Controller" [label="observations"];
+	"Controller" -> "Data Source" [label="actions"];
+	}
+	{rank="same"; "Controller"; "Result Logger"}
+	"Controller" -> "Result Logger" [label="internals"];
 	"Data Source" -> "Result Logger" [label="Simulated\n data"];
 }
@@ -87,15 +90,5 @@
 		if ( n_input>3 ) {
 			Cfg.addGroup ( input[3],"logger" );
-		}/*else{
-		// define logger as mexlog
-		Setting &S=Cfg.getRoot();
-		S.add("logger",Setting::TypeGroup);
-		S["logger"].add("class",Setting::TypeString);
-		S["logger"]["class"]="mexlog";
-		S["logger"].add("maxlen",Setting::TypeInt);
-		int maxlen;
-		S["experiment"].lookupValue("ndat",maxlen);
-		S["logger"]["maxlen"]=maxlen;
-	}*/
+		}
 	} catch ( SettingException e ) {
 		it_error ( "error: "+string ( e.getPath() ) );
@@ -116,8 +109,11 @@
 #endif
 
+	RNG_randomize();
+	
 	shared_ptr<DS> Ds = UI::build<DS> ( Cfg, "system" );
 	Array<shared_ptr<Controller> > Cs;
 	UI::get ( Cs,Cfg, "controllers" );
 	int Ndat=100;
+	int burnin=10;
 	if ( Cfg.exists ( "experiment" ) ) {
 		if ( Cfg.getRoot().lookupValue ( "experiment.ndat",Ndat ) ) {
@@ -178,4 +174,5 @@
 	}
 
+	vec ut(Ds->_urv()._dsize());
 	for ( int tK=0;tK<Ndat;tK++ ) {
 		Ds->getdata ( dt );					// read data
@@ -186,12 +183,15 @@
 				Cs(i) -> redesign();
 				Cs(i) -> adapt( Dlsc(i) ->pushdown(dt));
-				vec ut=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) );		// update estimates
-				Ds->write(ut, vec_1(0));
+			}
+			if (tK > burnin){
+				vec uti=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) );		// update estimates
+				Dlsu(i)->filldown(uti, ut);
 			} else {
-				Ds->write(0.001*randn(Ds->_urv()._dsize()));
+				ut = 0.1*randn(Ds->_urv()._dsize());
 			}
 			
 			Cs ( i )->log_write ();
 		}
+		Ds->write(ut);
 		
 		L->step();
