Index: bdm/estim/arx.cpp
===================================================================
--- bdm/estim/arx.cpp (revision 141)
+++ bdm/estim/arx.cpp (revision 162)
@@ -6,6 +6,13 @@
 	double lnc;
 
-	V.opupdt ( dt,frg );
-	nu+=frg;
+	if (frg<1.0) {
+		V*=frg;
+		nu*=frg;
+		if (evalll) {
+			last_lognc = est.lognc();
+		}
+	}
+	V.opupdt ( dt,1.0);
+	nu+=1.0;
 
 	if ( evalll ) {
Index: bdm/math/libDC.cpp
===================================================================
--- bdm/math/libDC.cpp (revision 141)
+++ bdm/math/libDC.cpp (revision 162)
@@ -183,6 +183,5 @@
 
 ldmat& ldmat::operator *= ( double x ) {
-	int i;
-	for ( i=0;i<D.length();i++ ){D( i )*=x;};
+	D*=x;
 	return *this;
 }
Index: bdm/stat/libEF.cpp
===================================================================
--- bdm/stat/libEF.cpp (revision 129)
+++ bdm/stat/libEF.cpp (revision 162)
@@ -112,28 +112,4 @@
 };
 
-vec mgamma::samplecond ( vec &cond, double &ll ) {
-	this->condition(cond );
-	vec smp = epdf.sample();
-	ll = epdf.evalpdflog ( smp );
-	return smp;
-};
-
-//Fixme repetition of mlnorm.samplecond.
-mat mgamma::samplecond ( vec &cond, vec &lik, int n ) {
-	int i;
-	int dim = rv.count();
-	mat Smp ( dim,n );
-	vec smp ( dim );
-	this->condition ( cond );
-
-	for ( i=0; i<n; i++ ) {
-		smp = epdf.sample();
-		lik ( i ) = epdf.eval ( smp );
-		Smp.set_col ( i ,smp );
-	}
-
-	return Smp;
-};
-
 ivec eEmp::resample ( RESAMPLING_METHOD method ) {
 	ivec ind=zeros_i ( n );
Index: bdm/stat/loggers.cpp
===================================================================
--- bdm/stat/loggers.cpp (revision 102)
+++ bdm/stat/loggers.cpp (revision 162)
@@ -8,9 +8,16 @@
 #endif
 
-void memlog::itsave(const char* fname){
-	it_file itf(fname);
+void memlog::itsave ( const char* fname ) {
+	it_file itf ( fname );
 	int i;
-	for (i=0; i<entries.length();i++){
-	 itf << Name(names(i)) << vectors(i);
+	for ( i=0; i<entries.length();i++ ) {
+		if ( names ( i ).length() <1 ) {
+			std::ostringstream o;
+			o<<"Variable"<<i;
+			itf << Name ( o.str() ) << vectors ( i );
+		}
+		else {
+			itf << Name ( names ( i ) ) << vectors ( i );
+		}
 	}
 }
@@ -26,5 +33,5 @@
 
 // Initialize directory
-	makedir(dirname); // 
+	makedir ( dirname ); //
 
 // directory OK, or it can be overwritten
@@ -40,5 +47,6 @@
 				scalarnames ( ii ) = names ( i ) + "_" + entries ( i ).name ( j );
 				ii++;
-			} else {
+			}
+			else {
 				for ( k=0;k<rvsize;k++ ) { //for all scalars in given RV
 					sprintf ( num,"%d",k );
@@ -62,4 +70,5 @@
 	memlog::init();
 
+	//Delete old data
 	write_buffers ( 0 );
 }
@@ -81,6 +90,6 @@
 	for ( i=0;i<nen;i++ ) { //for entries
 		Dt = vectors ( i )._data();
-		DtRows = vectors(i).rows();
-		
+		DtRows = vectors ( i ).rows();
+
 		jj=0;
 		for ( j=0;j<entries ( i ).length();j++ ) { //for RVs in entries
@@ -93,5 +102,5 @@
 						fp = open ( filename, O_CREAT | O_WRONLY | O_APPEND, 00644 );
 
-					write ( fp,&Dt[jj*(DtRows)],(Len)*sizeof ( double ) );
+					write ( fp,&Dt[jj* ( DtRows ) ], ( Len ) *sizeof ( double ) );
 					close ( fp );
 
@@ -106,15 +115,17 @@
 }
 
-void dirfilelog::step ( bool final ) {
+void dirfilelog::step ( ) {
 
-	if ( final ) {
-		if ( ind>0 )
-			write_buffers ( ind ); //assuming here that i+1 was not filled
-	} else
-		if ( ind== ( maxlen -1 ) ) {
-			write_buffers ( ind+1 );
-			ind = 0;
-		} else
-			ind++;
+	if ( ind== ( maxlen -1 ) ) {
+		write_buffers ( ind+1 );
+		ind = 0;
+	}
+	else
+		ind++;
 
 }
+
+void dirfilelog::finalize ( ) {
+	if ( ind>0 )
+		write_buffers ( ind ); //assuming here that i+1 was not filled
+}
Index: bdm/stat/libBM.cpp
===================================================================
--- bdm/stat/libBM.cpp (revision 145)
+++ bdm/stat/libBM.cpp (revision 162)
@@ -7,12 +7,13 @@
 using std::cout;
 
+static int RVcounter=0;
+
 void RV::init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times ) {
-	//
+	//Refer
 	int i;
 	len = in_ids.length();
 	//PRUDENT_MODE
 	// All vetors should be of same length
-	if ( ( len != in_ids.length() ) || \
-	        ( len != in_names.length() ) || \
+	if ( ( len != in_names.length() ) || \
 	        ( len != in_sizes.length() ) || \
 	        ( len != in_times.length() ) ) {
@@ -28,49 +29,70 @@
 };
 
-RV::RV ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times ) {
-	init ( in_ids, in_names, in_sizes, in_times );
+RV::RV ( Array<std::string> in_names, ivec in_sizes, ivec in_times ) {
+	int len = in_names.length();
+	init ( linspace ( RVcounter+1, RVcounter+len ), in_names, in_sizes, in_times );
+	RVcounter+=len;
 }
 
-RV::RV() : tsize ( 0 ), len ( 0 ) {};
+RV::RV ( Array<std::string> in_names, ivec in_sizes ) {
+	int len = in_names.length();
+	init ( linspace ( RVcounter+1, RVcounter+len ), in_names, in_sizes, zeros_i ( in_names.length() ) );
+	RVcounter+=len;
+}
+
+RV::RV ( Array<std::string> in_names ) {
+	int len = in_names.length();
+	init ( linspace ( RVcounter+1, RVcounter+len ), in_names, ones_i ( in_names.length() ), zeros_i ( in_names.length() ) );
+	RVcounter+=len;
+}
+
+RV::RV() : tsize ( 0 ), len ( 0 ), ids ( 0 ), names ( 0 ), sizes ( 0 ), times ( 0 ) {};
 
 bool RV::add ( const RV &rv2 ) {
 	// TODO
-	ivec ind = rv2.findself ( *this ); //should be -1 all the time
-	ivec index = itpp::find(ind==-1); 
-	
-	if ( index.length() < rv2.len ) { //conflict
-		ids = concat ( ids, rv2.ids(index) );
-		sizes = concat ( sizes, rv2.sizes(index) );
-		times = concat ( times, rv2.times(index) );
-		names = concat ( names, rv2.names(to_Arr(index)) );
+	if ( rv2.len>0 ) { //rv2 is nonempty
+		ivec ind = rv2.findself ( *this ); //should be -1 all the time
+		ivec index = itpp::find ( ind==-1 );
+
+
+		if ( index.length() < rv2.len ) { //conflict
+			ids = concat ( ids, rv2.ids ( index ) );
+			sizes = concat ( sizes, rv2.sizes ( index ) );
+			times = concat ( times, rv2.times ( index ) );
+			names = concat ( names, rv2.names ( to_Arr ( index ) ) );
+		}
+		else {
+			ids = concat ( ids, rv2.ids );
+			sizes = concat ( sizes, rv2.sizes );
+			times = concat ( times, rv2.times );
+			names = concat ( names, rv2.names );
+		}
+		tsize = sum ( sizes );
+		len = ids.length();
+		return ( index.length() <rv2.len );
 	}
-	else {
-		ids = concat ( ids, rv2.ids );
-		sizes = concat ( sizes, rv2.sizes );
-		times = concat ( times, rv2.times );
-		names = concat ( names, rv2.names );
+	else { //rv2 is empty
+		return true;
 	}
-	tsize = sum(sizes);
-	len = ids.length();
-	return (index.length()<rv2.len);
-
 //	return *this;
 };
 
-RV::RV ( ivec in_ids ) {
-
-	len = in_ids.length();
-	Array<std::string> A ( len );
-	std::string rvstr = "rv";
-
-	for ( int i = 0; i < len;i++ ) {
-		A ( i ) = rvstr + to_str ( i );
-	}
-
-	init ( in_ids, A, ones_i ( len ), zeros_i ( len ) );
-}
+// RV::RV ( ivec in_ids ) {
+//
+// 	len = in_ids.length();
+// 	Array<std::string> A ( len );
+// 	std::string rvstr = "rv";
+//
+// 	for ( int i = 0; i < len;i++ ) {
+// 		A ( i ) = rvstr + to_str ( i );
+// 	}
+//
+// 	init ( in_ids, A, ones_i ( len ), zeros_i ( len ) );
+// }
 
 RV RV::subselect ( ivec ind ) const {
-	return RV ( ids ( ind ), names ( to_Arr ( ind ) ), sizes ( ind ), times ( ind ) );
+	RV ret;
+	ret.init ( ids ( ind ), names ( to_Arr ( ind ) ), sizes ( ind ), times ( ind ) );
+	return ret;
 }
 
@@ -78,5 +100,9 @@
 
 RV RV::operator() ( ivec ind ) const {
-	return RV ( ids ( ind ), names ( to_Arr ( ind ) ), sizes ( ind ), times ( ind ) );
+	RV ret;
+	if ( ind.length() >0 ) {
+		ret.init ( ids ( ind ), names ( to_Arr ( ind ) ), sizes ( ind ), times ( ind ) );
+	}
+	return ret;
 }
 
@@ -127,4 +153,7 @@
 
 RV RV::subt ( const RV rv2 ) const {
+	cout << *this <<endl;
+	cout << rv2 <<endl;
+
 	ivec res = this->findself ( rv2 ); // nonzeros
 	ivec valid = itpp::find ( res == -1 ); //-1 => value not found => it remains
Index: bdm/stat/libEF.h
===================================================================
--- bdm/stat/libEF.h (revision 129)
+++ bdm/stat/libEF.h (revision 162)
@@ -270,8 +270,4 @@
 	//! Set value of \c k
 	void set_parameters ( double k );
-	//!Generate one sample of the posterior
-	vec samplecond ( vec &cond, double &lik );
-	//!Generate matrix of samples of the posterior
-	mat samplecond ( vec &cond, vec &lik, int n );
 	void condition ( const vec &val ) {*_beta=k/val;};
 };
Index: bdm/stat/emix.h
===================================================================
--- bdm/stat/emix.h (revision 148)
+++ bdm/stat/emix.h (revision 162)
@@ -31,31 +31,31 @@
 */
 class emix : public epdf {
-	protected:
-		//! weights of the components
-		vec w;
-		//! Component (epdfs)
-		Array<epdf*> Coms;
-	public:
-		//!Default constructor
-		emix(RV &rv) : epdf(rv) {};
-		//! Set weights \c w and components \c R
-		void set_parameters(const vec &w, const Array<epdf*> &Coms);
+protected:
+	//! weights of the components
+	vec w;
+	//! Component (epdfs)
+	Array<epdf*> Coms;
+public:
+	//!Default constructor
+	emix ( RV &rv ) : epdf ( rv ) {};
+	//! Set weights \c w and components \c R
+	void set_parameters ( const vec &w, const Array<epdf*> &Coms );
 
-		vec sample() const;
-		vec mean() const {
-			int i; vec mu = zeros(rv.count());
-			for (i = 0;i < w.length();i++) {mu += w(i) * Coms(i)->mean(); }
-			return mu;
-		}
-		double evalpdflog(const vec &val) const {
-			int i;
-			double sum = 0.0;
-			for (i = 0;i < w.length();i++) {sum += w(i) * Coms(i)->evalpdflog(val);}
-			return log(sum);
-		};
+	vec sample() const;
+	vec mean() const {
+		int i; vec mu = zeros ( rv.count() );
+		for ( i = 0;i < w.length();i++ ) {mu += w ( i ) * Coms ( i )->mean(); }
+		return mu;
+	}
+	double evalpdflog ( const vec &val ) const {
+		int i;
+		double sum = 0.0;
+		for ( i = 0;i < w.length();i++ ) {sum += w ( i ) * Coms ( i )->evalpdflog ( val );}
+		return log ( sum );
+	};
 
 //Access methods
-		//! returns a pointer to the internal mean value. Use with Care!
-		vec& _w() {return w;}
+	//! returns a pointer to the internal mean value. Use with Care!
+	vec& _w() {return w;}
 };
 
@@ -68,92 +68,104 @@
 Note that
 */
-class eprod: public epdf {
-	protected:
-		//
-		int n;
-		// pointers to epdfs
-		Array<epdf*> epdfs;
-		Array<mpdf*> mpdfs;
-		//
-		Array<ivec> rvinds;
-		Array<ivec> rvcinds;
-		//! Indicate independence of its factors
-		bool independent;
-		//! Indicate internal creation of mpdfs which must be destroyed
-		bool intermpdfs;
-	public:
-		//!Constructor from list of eFacs or list of mFacs
-		eprod(Array<mpdf*> mFacs): epdf(RV()), n(mFacs.length()), epdfs(n), mpdfs(mFacs), rvinds(n), rvcinds(n) {
-			int i;
-			intermpdfs = false;
-			for (i = 0;i < n;i++) {
-				rv.add(mpdfs(i)->_rv()); //add rv to common rvs.
-				epdfs(i) = &(mpdfs(i)->_epdf()); // add pointer to epdf
-			};
-			independent = true;
-			//test rvc of mpdfs and fill rvinds
-			for (i = 0;i < n;i++) {
-				// find ith rv in common rv
-				rvinds(i) = mpdfs(i)->_rv().dataind(rv);
-				// find ith rvc in common rv
-				rvcinds(i) = mpdfs(i)->_rvc().dataind(rv);
-				if (rvcinds(i).length()>0) {independent = false;}
-			}
-
+class mprod: public mpdf {
+protected:
+	//
+	int n;
+	// pointers to epdfs
+	Array<epdf*> epdfs;
+	Array<mpdf*> mpdfs;
+	//
+	//! Indeces of rvs in common rv
+	Array<ivec> rvinds;
+	//! Indeces of rvc in common rv
+	Array<ivec> rvcinrv;
+	//! Indeces of rvc in common rvc
+	Array<ivec> rvcinds;
+	//! Indicate independence of its factors
+	bool independent;
+//	//! Indicate internal creation of mpdfs which must be destroyed
+//	bool intermpdfs;
+public:
+	//!Constructor from list of eFacs or list of mFacs
+	mprod ( Array<mpdf*> mFacs ) : mpdf ( RV(), RV() ), n ( mFacs.length() ), epdfs ( n ), mpdfs ( mFacs ), rvinds ( n ), rvcinrv ( n ), rvcinds ( n ) {
+		int i;
+		// Create rv
+		for ( i = 0;i < n;i++ ) {
+			rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs.
+			epdfs ( i ) = & ( mpdfs ( i )->_epdf() ); // add pointer to epdf
 		};
-		eprod(Array<epdf*> eFacs): epdf(RV()), n(eFacs.length()), epdfs(eFacs), mpdfs(n), rvinds(n), rvcinds(n) {
-			int i;
-			intermpdfs = true;
-			for (i = 0;i < n;i++) {
-				if (rv.add(eFacs(i)->_rv())) {it_error("Incompatible eFacs.rv!");} //add rv to common rvs.
-				mpdfs(i) = new mepdf(*(epdfs(i)));
-				epdfs(i) = &(mpdfs(i)->_epdf()); // add pointer to epdf
-			};
-			independent = true;
-			//test rvc of mpdfs and fill rvinds
-			for (i = 0;i < n;i++) {
-				// find ith rv in common rv
-				rvinds(i) = mpdfs(i)->_rv().dataind(rv);
-			}
+		// Create rvc
+		for ( i = 0;i < n;i++ ) {
+			rvc.add ( mpdfs ( i )->_rv().subt ( rv ) ); //add rv to common rvs.
 		};
 
-		double evalpdflog(const vec &val) const {
-			int i;
-			double res = 0.0;
-			for (i = n - 1;i > 0;i++) {
-				if (rvcinds(i).length() > 0)
-					{mpdfs(i)->condition(val(rvcinds(i)));}
-				// add logarithms
-				res += epdfs(i)->evalpdflog(val(rvinds(i)));
+		independent = true;
+		//test rvc of mpdfs and fill rvinds
+		for ( i = 0;i < n;i++ ) {
+			// find ith rv in common rv
+			rvinds ( i ) = mpdfs ( i )->_rv().dataind ( rv );
+			// find ith rvc in common rv
+			rvcinrv ( i ) = mpdfs ( i )->_rvc().dataind ( rv );
+			// find ith rvc in common rv
+			rvcinds ( i ) = mpdfs ( i )->_rvc().dataind ( rvc );
+			//
+			if ( rvcinds ( i ).length() >0 ) {independent = false;}
+			if ( rvcinds ( i ).length() >0 ) {independent = false;}
+		}
+	};
+
+	double evalpdflog ( const vec &val ) const {
+		int i;
+		double res = 0.0;
+		for ( i = n - 1;i > 0;i++ ) {
+			if ( rvcinds ( i ).length() > 0 )
+				{mpdfs ( i )->condition ( val ( rvcinds ( i ) ) );}
+			// add logarithms
+			res += epdfs ( i )->evalpdflog ( val ( rvinds ( i ) ) );
+		}
+		return res;
+	}
+	vec samplecond ( const vec &cond, double &ll ) {
+		vec smp=zeros ( rv.count() );
+		vec condi;
+		for ( int i = ( n - 1 );i >= 0;i-- ) {
+			if ( rvcinds ( i ).length() > 0 ) {
+				condi = zeros ( rvcinrv.length() + rvcinds.length() );
+				// copy data in condition
+				set_subvector ( condi,rvcinds ( i ), cond );
+				// copy data in already generated sample
+				set_subvector ( condi,rvcinrv ( i ), smp );
+
+				mpdfs ( i )->condition ( condi );
 			}
-			return res;
+			// copy contribution of this pdf into smp
+			set_subvector ( smp,rvinds ( i ), epdfs ( i )->sample() );
 		}
-		vec sample () const{
-			vec smp=zeros(rv.count());
-			for (int i = (n - 1);i >= 0;i--) {
-				if (rvcinds(i).length() > 0)
-					{mpdfs(i)->condition(smp(rvcinds(i)));}
-				set_subvector(smp,rvinds(i), epdfs(i)->sample());
-			}			
-			return smp;
-		}
-		vec mean() const{
-			vec tmp(rv.count());
-			if (independent) {
-				for (int i=0;i<n;i++) {
-					vec pom = epdfs(i)->mean();
-					set_subvector(tmp,rvinds(i), pom);
-				}
-			}
-			else {
-				int N=50*rv.count();
-				it_warning("eprod.mean() computed by sampling");
-				tmp = zeros(rv.count());
-				for (int i=0;i<N;i++){ tmp += sample();}
-				tmp /=N;
-			}
-			return tmp;
-		}
-		~eprod(){if (intermpdfs) {for (int i=0;i<n;i++){delete mpdfs(i);}}};
+		return smp;
+	}
+	mat samplecond ( const vec &cond, vec &ll, int N ) {
+		mat Smp(rv.count(),N);
+		for(int i=0;i<N;i++){Smp.set_col(i,samplecond(cond,ll(i)));}
+		return Smp;
+	}
+// 	vec mean() const {
+// 		vec tmp ( rv.count() );
+// 		if ( independent ) {
+// 			for ( int i=0;i<n;i++ ) {
+// 				vec pom = epdfs ( i )->mean();
+// 				set_subvector ( tmp,rvinds ( i ), pom );
+// 			}
+// 		}
+// 		else {
+// 			int N=50*rv.count();
+// 			it_warning ( "eprod.mean() computed by sampling" );
+// 			tmp = zeros ( rv.count() );
+// 			for ( int i=0;i<N;i++ ) { tmp += sample();}
+// 			tmp /=N;
+// 		}
+// 		return tmp;
+// 	}
+
+	~mprod() {};
 };
 
@@ -162,25 +174,25 @@
 */
 class mmix : public mpdf {
-	protected:
-		//! Component (epdfs)
-		Array<mpdf*> Coms;
-		//!Internal epdf
-		emix Epdf;
-	public:
-		//!Default constructor
-		mmix(RV &rv, RV &rvc) : mpdf(rv, rvc), Epdf(rv) {ep = &Epdf;};
-		//! Set weights \c w and components \c R
-		void set_parameters(const vec &w, const Array<mpdf*> &Coms) {
-			Array<epdf*> Eps(Coms.length());
+protected:
+	//! Component (epdfs)
+	Array<mpdf*> Coms;
+	//!Internal epdf
+	emix Epdf;
+public:
+	//!Default constructor
+	mmix ( RV &rv, RV &rvc ) : mpdf ( rv, rvc ), Epdf ( rv ) {ep = &Epdf;};
+	//! Set weights \c w and components \c R
+	void set_parameters ( const vec &w, const Array<mpdf*> &Coms ) {
+		Array<epdf*> Eps ( Coms.length() );
 
-			for (int i = 0;i < Coms.length();i++) {
-				Eps(i) = & (Coms(i)->_epdf());
-			}
-			Epdf.set_parameters(w, Eps);
-		};
+		for ( int i = 0;i < Coms.length();i++ ) {
+			Eps ( i ) = & ( Coms ( i )->_epdf() );
+		}
+		Epdf.set_parameters ( w, Eps );
+	};
 
-		void condition(const vec &cond) {
-			for (int i = 0;i < Coms.length();i++) {Coms(i)->condition(cond);}
-		};
+	void condition ( const vec &cond ) {
+		for ( int i = 0;i < Coms.length();i++ ) {Coms ( i )->condition ( cond );}
+	};
 };
 #endif //MX_H
Index: bdm/stat/loggers.h
===================================================================
--- bdm/stat/loggers.h (revision 145)
+++ bdm/stat/loggers.h (revision 162)
@@ -37,5 +37,5 @@
 
 //! returns an identifier which will be later needed for calling the log() function
-	virtual int add ( RV rv, string name="" ) {
+	virtual int add (const RV &rv, string name="" ) {
 		int id=entries.length();
 		names=concat ( names, name ); // diff
@@ -48,6 +48,9 @@
 	virtual void logit ( int id, vec v ) =0;
 
-//! consider this record to be complete
-	virtual void step(bool final=false) =0;
+//! Shifts storage position for another time step.
+	virtual void step() =0;
+
+	//! Finalize storing information
+	virtual void finalize() {};
 
 	//! for future use
@@ -82,6 +85,8 @@
 		;
 	}
-	void step(bool final=false) {if ( ind<maxlen ) ind++; else it_error ( "memlog::ind is too high;" );}
-	void logit ( int id, vec v ) {vectors ( id ).set_row ( ind,v );}
+	void step() {if ( ind<maxlen ) ind++; else it_error ( "memlog::ind is too high;" );}
+	void logit ( int id, vec v ) {
+		it_assert_debug(id<vectors.length(),"Logger was not initialized, run init().");
+		vectors ( id ).set_row ( ind,v );}
 	//! Save values into an itfile named after \c fname.
 	void itsave(const char* fname);
@@ -110,5 +115,6 @@
 	//! Initialize storage
 	void init();
-	void step(bool final=false);
+	void step();
+	void finalize();
 	/*! \brief Write memory storage to disk. 
 	@param Len length of buffer to be written, if 0 the file is truncated at 0.
Index: bdm/stat/libBM.h
===================================================================
--- bdm/stat/libBM.h (revision 145)
+++ bdm/stat/libBM.h (revision 162)
@@ -52,11 +52,13 @@
 private:
 	//! auxiliary function used in constructor
-	void init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times );
-public:
-	//! Full constructor which is called by the others
-	RV ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times );
-	//! default constructor
-	RV ( ivec ids );
-	//! Empty constructor will be set later
+	void init (ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times );
+public:
+	//! Full constructor 
+	RV ( Array<std::string> in_names, ivec in_sizes, ivec in_times );
+	//! Constructor with times=0
+	RV ( Array<std::string> in_names, ivec in_sizes );
+	//! Constructor with sizes=1, times=0
+	RV ( Array<std::string> in_names );
+	//! Constructor of empty RV
 	RV ();
 
@@ -137,5 +139,5 @@
 public:
 	//!default constructor
-	epdf() :rv ( ivec ( 0 ) ) {};
+	epdf() :rv ( ) {};
 
 	//!default constructor
@@ -180,9 +182,9 @@
 //	virtual fnc moment ( const int order = 1 );
 	//! Returns a sample from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv \param ll is a return value of log-likelihood of the sample.
-	virtual vec samplecond ( vec &cond, double &ll ) {this->condition ( cond );
+	virtual vec samplecond (const vec &cond, double &ll ) {this->condition ( cond );
 	vec temp= ep->sample();
 	ll=ep->evalpdflog ( temp );return temp;};
 	//! Returns \param N samples from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv \param ll is a return value of log-likelihood of the sample.
-	virtual mat samplecond ( vec &cond, vec &ll, int N ) {
+	virtual mat samplecond (const vec &cond, vec &ll, int N ) {
 		this->condition ( cond );
 		mat temp ( rv.count(),N ); vec smp ( rv.count() ); 
Index: bdm/CMakeLists.txt
===================================================================
--- bdm/CMakeLists.txt (revision 143)
+++ bdm/CMakeLists.txt (revision 162)
@@ -2,5 +2,5 @@
 
 SET(BdmMath math/libDC.cpp math/libDC.h math/chmat.cpp math/chmat.h)
-SET(BdmStat stat/libDS.cpp stat/libDS.h stat/libFN.cpp stat/libFN.h stat/libBM.cpp stat/libBM.h stat/libEF.cpp stat/libEF.h stat/loggers.cpp stat/loggers.h stat/emix.cpp stat/emix.h)
+SET(BdmStat stat/libDS.cpp stat/libDS.h stat/libFN.cpp stat/libFN.h stat/libBM.cpp stat/libBM.h stat/libEF.cpp stat/libEF.h stat/loggers.cpp stat/loggers.h stat/emix.cpp stat/emix.h stat/merger.cpp)
 SET(BdmEstim estim/libKF.cpp estim/libKF.h estim/libPF.cpp estim/libPF.h estim/arx.cpp estim/arx.h)
 SET(BdmUI userinfo.cpp userinfo.h)
