Index: library/bdm/stat/merger.h
===================================================================
--- library/bdm/stat/merger.h (revision 1072)
+++ library/bdm/stat/merger.h (revision 1079)
@@ -32,11 +32,11 @@
 		//! weights of the sources -- no restrictions
 		vec w;
-		//! get ith source
+		//! source pdfs -- conditioning allowed
 		Array<shared_ptr<epdf> > sources;
 		//! merge 
-		void merge() NOT_IMPLEMENTED_VOID;
+		virtual void merge() NOT_IMPLEMENTED_VOID;
 		//! 
 		//! check if all epdfs are on the same support
-		void validate() {
+		void validate_sources() {
 			int n=sources.length();
 			
@@ -75,8 +75,13 @@
 			vec mea=zeros(dim);
 			// go through all sources
+			epdf * si;
 			for (int i=0; i<n; i++){
-				sq_T Ci = sources(i)->covariance();
+				si = dynamic_cast<epdf*>(sources(i).get());  // transform pdf into epdf
+
+				if (!si) {bdm_error("Can't merger this type of pdf: " + sources(i)->to_string());}
+				
+				sq_T Ci = si->covariance();
 				sq_T wCi = Ci; wCi*=w(i);
-				vec mi = sources(i)->mean();
+				vec mi = si->mean();
 				switch (method) {
 					case ARITHMETIC:{
@@ -133,10 +138,12 @@
 However, these operations can not be performed in general. Hence, this class merges only sources on common support, \f$ y_i={}, z_i={}, \forall i \f$.
 For merging of more general cases, use offsprings merger_mix and merger_grid.
+
+\TODO use sources for extensions
 */
-class merger_base : public epdf {
+class MergerDiscrete : public MergerBase {
 protected:
-    //! Elements of composition
-    Array<shared_ptr<pdf> > pdfs;
-
+	//! partial sources
+	Array<shared_ptr< pdf > > part_sources;
+	
     //! Data link for each pdf in pdfs
     Array<datalink_m2e*> dls;
@@ -177,12 +184,12 @@
 
     //! Default constructor
-    merger_base () : Npoints ( 0 ), Nsources ( 0 ), DBG ( false ), dbg_file ( 0 ) {
+    MergerDiscrete () : Npoints ( 0 ), Nsources ( 0 ), DBG ( false ), dbg_file ( 0 ) {
     }
 
     //!Constructor from sources
-    merger_base ( const Array<shared_ptr<pdf> > &S );
+    MergerDiscrete ( const Array<shared_ptr<pdf> > &S );
 
     //! Function setting the main internal structures
-    void set_sources ( const Array<shared_ptr<pdf> > &Sources );
+    void set_sources ( const Array<shared_ptr<pdf> > &PartSources );
 
     //! Set support points from rectangular grid
@@ -205,5 +212,5 @@
 
     //! Set internal parameters used in approximation
-    void set_method ( MERGER_METHOD MTH = DFLT_METHOD, double beta0 = DFLT_beta ) {
+    void set_method ( MERGER_METHOD MTH = GEOMETRIC, double beta0 = 1.2 ) {
         METHOD = MTH;
         beta = beta0;
@@ -216,5 +223,5 @@
 
     //! Destructor
-    virtual ~merger_base() {
+    virtual ~MergerDiscrete() {
         for ( int i = 0; i < Nsources; i++ ) {
             delete dls ( i );
@@ -229,25 +236,10 @@
 
     //!Merge given sources in given points
-    virtual void merge ();
+    void merge ();
 
     //! Merge log-likelihood values in points using method specified by parameter METHOD
     vec merge_points ( mat &lW );
 
-
-    //! sample from merged density
-//! weight w is a
-    vec mean() const;
-
-    mat covariance() const;
-
-    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);
-
-    //!@}
+  //!@}
 
     //! \name Access to attributes
@@ -258,4 +250,6 @@
         return eSmp;
     }
+
+	eEmp & merger() {return eSmp;}
 
     /*! Create object from the following structure
@@ -279,9 +273,9 @@
     //!@}
 };
-UIREGISTER ( merger_base );
-SHAREDPTR ( merger_base );
+UIREGISTER ( MergerDiscrete );
+SHAREDPTR ( MergerDiscrete );
 
 //! \brief Merger using importance sampling with mixture proposal density
-class merger_mix : public merger_base {
+class merger_mix : public MergerDiscrete {
 protected:
     //!Internal mixture of EF models
@@ -311,5 +305,5 @@
     //! Set sources and prepare all internal structures
     void set_sources ( const Array<shared_ptr<pdf> > &S ) {
-        merger_base::set_sources ( S );
+        MergerDiscrete::set_sources ( S );
         //Nsources = S.length();
     }
@@ -349,5 +343,5 @@
     emix* proposal() {
         emix* tmp = Mix.epredictor();
-        tmp->set_rv ( rv );
+        tmp->set_rv ( merger()._rv() );
         return tmp;
     }
@@ -376,4 +370,5 @@
     void validate();
 
+//	const emix &merger(){return *Mpred;}
     //! @}
 };
