Index: library/bdm/stat/discrete.cpp
===================================================================
--- library/bdm/stat/discrete.cpp (revision 760)
+++ library/bdm/stat/discrete.cpp (revision 766)
@@ -81,5 +81,5 @@
 				inds ( j ) = gridsizes ( j ) - 1;
 			else {
-				inds ( j ) = ::round ( val ( j ) - ranges ( j ) ( 0 ) / steps ( j ) );
+				inds ( j ) = (int) ::round ( val ( j ) - ranges ( j ) ( 0 ) / steps ( j ) );
 			}
 		}
Index: library/bdm/stat/emix.cpp
===================================================================
--- library/bdm/stat/emix.cpp (revision 760)
+++ library/bdm/stat/emix.cpp (revision 766)
@@ -3,29 +3,33 @@
 namespace bdm {
 
-void emix::set_parameters ( const vec &w0, const Array<shared_ptr<epdf> > &Coms0 ) {
-	w = w0 / sum ( w0 );
-	
-	bool isnamed = Coms0 ( 0 )->isnamed();
-	RV tmp_rv;
-	if ( isnamed ) tmp_rv = Coms0 ( 0 )->_rv();
-	Coms = Coms0;
-
-	if ( isnamed ) epdf::set_rv ( tmp_rv ); //coms aer already OK, no need for set_rv
-}
-
 void emix::validate (){
-	dim = Coms ( 0 )->dimension();
-	bool isnamed = Coms ( 0 )->isnamed();
-	int i;
-	RV tmp_rv;
-	if ( isnamed ) tmp_rv = Coms ( 0 )->_rv();
-	for ( i = 0; i < w.length(); i++ ) {
+	bdm_assert ( Coms.length() > 0, "There has to be at least one component." );
+
+	bdm_assert ( Coms.length() == w.length(), "It is obligatory to define weights of all the components." );
+
+	double sum_w = sum ( w );
+	bdm_assert ( sum_w != 0, "There has to be a component with non-zero weight." );
+	w = w / sum_w;
+
+	int dim = Coms ( 0 )->dimension();
+	for ( int i = 1; i < Coms.length(); i++ ) {
 		bdm_assert ( dim == ( Coms ( i )->dimension() ), "Component sizes do not match!" );
-		bdm_assert ( !isnamed || tmp_rv.equal ( Coms ( i )->_rv() ), "Component RVs do not match!" );
-	}
-
-}
-
-
+		bdm_assert ( Coms(i)->isnamed() , "An unnamed component is forbidden here!" );
+	}
+
+	set_rv ( Coms ( 0 )->_rv() ); 
+}
+
+void emix::from_setting ( const Setting &set ) {
+	UI::get ( Coms, set, "pdfs", UI::compulsory );
+
+	if ( !UI::get ( w, set, "weights", UI::optional ) ) {
+		int len = Coms.length();
+		w.set_length ( len );
+		w = 1.0 / len;
+	}
+
+	validate();
+}
 
 
@@ -109,5 +113,6 @@
 	}
 
-	target.set_parameters ( w, Cn );
+	target._w() = w;
+	target._Coms() = Cn;
 	target.validate();
 }
@@ -190,5 +195,6 @@
 	}
 
-	target.set_parameters ( w, Cn );
+	target._w() = w;
+	target._Coms() = Cn;
 	target.validate();
 }
@@ -313,4 +319,36 @@
 		dls ( i ) = new datalink_m2m;
 		dls ( i )->set_connection ( pdfs ( i )->_rv(), pdfs ( i )->_rvc(), _rv(), _rvc() );
+	}
+}
+
+void mmix::validate()
+{	
+	bdm_assert ( Coms.length() > 0, "There has to be at least one component." );
+
+	bdm_assert ( Coms.length() == w.length(), "It is obligatory to define weights of all the components." );
+
+	double sum_w = sum ( w );
+	bdm_assert ( sum_w != 0, "There has to be a component with non-zero weight." );
+	w = w / sum_w;
+
+	int dim = Coms ( 0 )->dimension();
+	int dimc = Coms ( 0 )->dimensionc();
+	for ( int i = 1; i < Coms.length(); i++ ) {
+		bdm_assert ( dim == ( Coms ( i )->dimension() ), "Component sizes do not match!" );
+		bdm_assert ( dimc == ( Coms ( i )->dimensionc() ), "Component sizes do not match!" );
+		bdm_assert ( Coms(i)->isnamed() , "An unnamed component is forbidden here!" );
+	}
+
+	set_rv ( Coms ( 0 )->_rv() );
+	set_rvc ( Coms ( 0 )->_rvc() );
+}
+
+void mmix::from_setting ( const Setting &set ) {
+	UI::get ( Coms, set, "pdfs", UI::compulsory );
+
+	if ( !UI::get ( w, set, "weights", UI::optional ) ) {
+		int len = Coms.length();
+		w.set_length ( len );
+		w = 1.0 / len;
 	}
 }
Index: library/bdm/stat/exp_family.h
===================================================================
--- library/bdm/stat/exp_family.h (revision 763)
+++ library/bdm/stat/exp_family.h (revision 766)
@@ -44,8 +44,5 @@
 
 	//!Evaluate normalized log-probability
-	virtual double evallog_nn ( const vec &val ) const {
-		bdm_error ( "Not implemented" );
-		return 0.0;
-	}
+	virtual double evallog_nn ( const vec &val ) const NOT_IMPLEMENTED(0);
 
 	//!Evaluate normalized log-probability
@@ -73,7 +70,5 @@
 
 	//!Power of the density, used e.g. to flatten the density
-	virtual void pow ( double p ) {
-		bdm_error ( "Not implemented" );
-	}
+	virtual void pow ( double p ) NOT_IMPLEMENTED_VOID;
 };
 
@@ -92,7 +87,5 @@
 	BMEF ( const BMEF &B ) : BM ( B ), frg ( B.frg ), last_lognc ( B.last_lognc ) {}
 	//!get statistics from another model
-	virtual void set_statistics ( const BMEF* BM0 ) {
-		bdm_error ( "Not implemented" );
-	}
+	virtual void set_statistics ( const BMEF* BM0 ) NOT_IMPLEMENTED_VOID;
 
 	//! Weighted update of sufficient statistics (Bayes rule)
@@ -102,17 +95,16 @@
 
 	//!Flatten the posterior according to the given BMEF (of the same type!)
-	virtual void flatten ( const BMEF * B ) {
-		bdm_error ( "Not implemented" );
-	}
-
-	BMEF* _copy_ () const {
-		bdm_error ( "function _copy_ not implemented for this BM" );
-		return NULL;
-	}
+	virtual void flatten ( const BMEF * B ) NOT_IMPLEMENTED_VOID;
+
+	double logpred ( const vec &yt ) const NOT_IMPLEMENTED(0);
+	
+	virtual epdf* epredictor() const NOT_IMPLEMENTED(NULL);
+
+	virtual pdf* predictor() const NOT_IMPLEMENTED(NULL);
 
 	void to_setting ( Setting &set ) const
 	{			
 		BM::to_setting( set );
-		// TODO DOPLNIT? CHYBI FROM_SETTING PRO INSPIRACI
+		// TODO DOPLNIT? ALE MOMENTALNE CHYBI FROM_SETTING PRO INSPIRACI
 	} 
 };
@@ -1112,4 +1104,5 @@
 	//! Constructor
 	migamma_ref () : migamma (), refl () {};
+	
 	//! Set value of \c k
 	void set_parameters ( double k0 , vec ref0, double l0 ) {
@@ -1266,15 +1259,26 @@
 		return X*Y._Ch();// return upper triangular part of the decomposition
 	}
+
 	vec sample () const {
 		return vec ( sample_mat()._data(), p*p );
 	}
+
+	virtual vec mean() const NOT_IMPLEMENTED(0);
+
+	//! return expected variance (not covariance!)
+	virtual vec variance() const NOT_IMPLEMENTED(0);
+
+	virtual double evallog ( const vec &val ) const NOT_IMPLEMENTED(0);
+
 	//! fast access function y0 will be copied into Y.Ch.
 	void setY ( const mat &Ch0 ) {
 		copy_vector ( dim, Ch0._data(), Y._Ch()._data() );
 	}
+
 	//! fast access function y0 will be copied into Y.Ch.
 	void _setY ( const vec &ch0 ) {
 		copy_vector ( dim, ch0._data(), Y._Ch()._data() );
 	}
+
 	//! access function
 	const chmat& getY() const {
@@ -1321,4 +1325,5 @@
 		W.setY ( iCh );
 	}
+
 	virtual double evallog ( const vec &val ) const {
 		chmat X ( p );
@@ -1345,4 +1350,8 @@
 	};
 
+	virtual vec mean() const NOT_IMPLEMENTED(0);
+
+	//! return expected variance (not covariance!)
+	virtual vec variance() const NOT_IMPLEMENTED(0);
 };
 
@@ -1464,14 +1473,8 @@
 
 	//! inherited operation : NOT implemented
-	vec sample() const {
-		bdm_error ( "Not implemented" );
-		return vec();
-	}
+	vec sample() const NOT_IMPLEMENTED(0);
 
 	//! inherited operation : NOT implemented
-	double evallog ( const vec &val ) const {
-		bdm_error ( "Not implemented" );
-		return 0.0;
-	}
+	double evallog ( const vec &val ) const NOT_IMPLEMENTED(0);
 
 	vec mean() const {
Index: library/bdm/stat/merger.h
===================================================================
--- library/bdm/stat/merger.h (revision 763)
+++ library/bdm/stat/merger.h (revision 766)
@@ -148,4 +148,10 @@
 
 	vec variance() const;
+
+	//! Compute log-probability of argument \c val
+	virtual double evallog ( const vec &val ) const NOT_IMPLEMENTED(0);
+
+	//! Returns a sample, \f$ x \f$ from density \f$ f_x()\f$
+	virtual vec sample() const NOT_IMPLEMENTED(0);
 
 	//!@}
Index: library/bdm/stat/emix.h
===================================================================
--- library/bdm/stat/emix.h (revision 750)
+++ library/bdm/stat/emix.h (revision 766)
@@ -53,5 +53,5 @@
 		// adjust rv and rvc
 
-		set_rv ( rv ); // TODO co kdyby tohle samo uz nastavovalo dimension?!?!
+		set_rv ( rv ); 
 		dim = rv._dsize();
 
@@ -81,4 +81,8 @@
 		return tmp;
 	}
+
+	//! 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
+	virtual vec samplecond ( const vec &cond ) NOT_IMPLEMENTED(0);
+
 	//! Object takes ownership of nom and will destroy it
 	void ownnom() {
@@ -91,4 +95,7 @@
 		}
 	}
+
+
+
 
 private:
@@ -120,12 +127,4 @@
 	emix ( ) : epdf ( ) { }
 
-	/*!
-	  \brief Set weights \c w and components \c Coms
-
-	  Shared pointers in Coms are kept inside this instance and
-	  shouldn't be modified after being passed to this method.
-	*/
-	void set_parameters ( const vec &w, const Array<shared_ptr<epdf> > &Coms );
-    
 	virtual void validate ();
 
@@ -148,11 +147,21 @@
 	shared_ptr<pdf> condition ( const RV &rv ) const;
 
-	//Access methods
-	//! returns a pointer to the internal mean value. Use with Care!
+	//Access methods	
+	//! returns a reference to the internal weights. Use with Care!
 	vec& _w() {
 		return w;
 	}
 
-	//!access function
+	/*!
+	  \brief returns a reference to the internal array of components. Use with Care! Set components \c Coms
+
+	  Shared pointers in Coms are kept inside this instance and
+	  shouldn't be modified after being passed to this method.
+	*/
+	Array<shared_ptr<epdf>>& _Coms ( ) {
+		return Coms;
+	}
+
+	//! returns a reference to the internal components specified by index i. Use with Care!
 	shared_ptr<epdf> _Coms ( int i ) {
 		return Coms ( i );
@@ -174,21 +183,5 @@
 	//! \endcode
 	//!@}
-	void from_setting ( const Setting &set ) {
-
-		vec w0;
-		Array<shared_ptr<epdf> > Coms0;
-
-		UI::get ( Coms0, set, "pdfs", UI::compulsory );
-
-		if ( !UI::get ( w0, set, "weights", UI::optional ) ) {
-			int len = Coms.length();
-			w0.set_length ( len );
-			w0 = 1.0 / len;
-		}
-
-		// TODO asi lze nacitat primocare do w a coms, jen co bude hotovy validate()
-		set_parameters ( w0, Coms0 );
-		validate();
-	}
+	void from_setting ( const Setting &set );
 };
 SHAREDPTR ( emix );
@@ -284,8 +277,4 @@
 	//! Data link for each pdfs
 	Array<shared_ptr<datalink_m2m> > dls;
-
-protected:
-	//! dummy epdf used only as storage for RV and dim
-	epdf iepdf;
 
 public:
@@ -330,7 +319,7 @@
 	//!@}
 	void from_setting ( const Setting &set ) {
-		Array<shared_ptr<pdf> > atmp; //temporary Array
-		UI::get ( atmp, set, "pdfs", UI::compulsory );
-		set_elements ( atmp );
+		Array<shared_ptr<pdf> > temp_array; 
+		UI::get ( temp_array, set, "pdfs", UI::compulsory );
+		set_elements ( temp_array );
 	}
 };
@@ -418,17 +407,4 @@
 	mmix() : Coms ( 0 ) { }
 
-	//! Set weights \c w and components \c R
-	void set_parameters ( const vec &w0, const Array<shared_ptr<pdf> > &Coms0 ) {
-		//!\todo check if all components are OK
-		Coms = Coms0;
-		w = w0;
-
-		if ( Coms0.length() > 0 ) {
-			set_rv ( Coms ( 0 )->_rv() );
-			dim = rv._dsize();
-			set_rvc ( Coms ( 0 )->_rvc() );
-			dimc = rvc._dsize();
-		}
-	}
 	double evallogcond ( const vec &dt, const vec &cond ) {
 		double ll = 0.0;
@@ -449,21 +425,7 @@
 	//! \endcode
 	//!@}
-	void from_setting ( const Setting &set ) {
-		UI::get ( Coms, set, "pdfs", UI::compulsory );
-
-		// TODO ma byt zde, ci ve validate()?
-		if ( Coms.length() > 0 ) {
-			set_rv ( Coms ( 0 )->_rv() );
-			dim = rv._dsize();
-			set_rvc ( Coms ( 0 )->_rvc() );
-			dimc = rvc._dsize();
-		}
-
-		if ( !UI::get ( w, set, "weights", UI::optional ) ) {
-			int len = Coms.length();
-			w.set_length ( len );
-			w = 1.0 / len;
-		}
-	}
+	void from_setting ( const Setting &set );
+
+	virtual void validate();
 };
 SHAREDPTR ( mmix );
