Index: bdm/stat/libBM.h
===================================================================
--- bdm/stat/libBM.h (revision 96)
+++ bdm/stat/libBM.h (revision 102)
@@ -31,5 +31,5 @@
 	//! len = number of individual rvs
 	int len;
-	//! Vector of unique IDs 
+	//! Vector of unique IDs
 	ivec ids;
 	//! Vector of sizes
@@ -42,8 +42,8 @@
 private:
 	//! auxiliary function used in constructor
-	void init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times);
+	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);
+	RV ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times );
 	//! default constructor
 	RV ( ivec ids );
@@ -63,8 +63,10 @@
 	//! Find indexes of another rv in self
 	ivec find ( RV rv2 );
+	//! Compare if \c rv2 is identical to this \c RV
+	bool equal ( RV rv2 ) const;
 	//! Add (concat) another variable to the current one
- 	void add (const RV &rv2 );
+	void add ( const RV &rv2 );
 	//! Add (concat) another variable to the current one
-	friend RV concat (const RV &rv1, const RV &rv2 );
+	friend RV concat ( const RV &rv1, const RV &rv2 );
 	//! Subtract  another variable from the current one
 	RV subt ( RV rv2 );
@@ -79,14 +81,14 @@
 
 	//!access function
-	Array<std::string>& _names(){return names;};
-
-	//!access function
-	int id(int at){return ids(at);};
-	//!access function
-	int size(int at){return sizes(at);};
-	//!access function
-	int time(int at){return times(at);};
-	//!access function
-	std::string name(int at){return names(at);};
+	Array<std::string>& _names() {return names;};
+
+	//!access function
+	int id ( int at ) {return ids ( at );};
+	//!access function
+	int size ( int at ) {return sizes ( at );};
+	//!access function
+	int time ( int at ) {return times ( at );};
+	//!access function
+	std::string name ( int at ) {return names ( at );};
 };
 
@@ -100,9 +102,9 @@
 public:
 	//!default constructor
-	fnc(int dy):dimy(dy){};
+	fnc ( int dy ) :dimy ( dy ) {};
 	//! function evaluates numerical value of \f$f(x)\f$ at \f$x=\f$ \c cond
 	virtual vec eval ( const vec &cond ) {
 		return vec ( 0 );
-	}; 
+	};
 
 	//! access function
@@ -131,13 +133,15 @@
 	//! Returns a sample, \f$x\f$ from density \f$epdf(rv)\f$
 	virtual vec sample () const =0;
+	//! Returns N samples from density \f$epdf(rv)\f$
+	virtual mat sampleN ( int N ) const;
 	//! Compute probability of argument \c val
-	virtual double eval ( const vec &val ) const {return exp(this->evalpdflog(val));};
+	virtual double eval ( const vec &val ) const {return exp ( this->evalpdflog ( val ) );};
 
 	//! Compute log-probability of argument \c val
 	virtual double evalpdflog ( const vec &val ) const =0;
 
-	//! return expected value 
+	//! return expected value
 	virtual vec mean() const =0;
-	
+
 	//! Destructor for future use;
 	virtual ~epdf() {};
@@ -163,10 +167,16 @@
 //	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);vec temp= ep->sample();ll=ep->evalpdflog(temp);return temp;};
+	virtual vec samplecond ( vec &cond, double &ll ) {this->condition ( cond );vec temp= ep->sample();ll=ep->evalpdflog ( temp );return temp;};
+	//! Returns 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 ) {
+		this->condition ( cond );
+		mat temp ( rv.count(),N ); vec smp ( rv.count() ); for ( int i=0;i<N;i++ ) {smp=ep->sample() ;temp.set_col ( i, smp );ll ( i ) =ep->evalpdflog ( smp );}
+		return temp;
+	};
 	//! Update \c ep so that it represents this mpdf conditioned on \c rvc = cond
 	virtual void condition ( const vec &cond ) {};
-	
+
 	//! Shortcut for conditioning and evaluation of the internal epdf. In some cases,  this operation can be implemented efficiently.
-	virtual double evalcond (const vec &dt, const vec &cond ) {this->condition(cond);return ep->eval(dt);};
+	virtual double evalcond ( const vec &dt, const vec &cond ) {this->condition ( cond );return ep->eval ( dt );};
 
 	//! Destructor for future use;
@@ -176,7 +186,7 @@
 	mpdf ( const RV &rv0, const RV &rvc0 ) :rv ( rv0 ),rvc ( rvc0 ) {};
 	//! access function
-	RV _rvc(){return rvc;}
-	//!access function
-	epdf& _epdf(){return *ep;}
+	RV _rvc() {return rvc;}
+	//!access function
+	epdf& _epdf() {return *ep;}
 };
 
@@ -230,5 +240,5 @@
 
 	//!Default constructor
-	BM(const RV &rv0) :rv(rv0), ll ( 0 ),evalll ( true ) {//Fixme: test rv 
+	BM ( const RV &rv0 ) :rv ( rv0 ), ll ( 0 ),evalll ( true ) {//Fixme: test rv
 	};
 
@@ -240,5 +250,5 @@
 	void bayes ( mat Dt );
 	//! Returns a pointer to the epdf representing posterior density on parameters. Use with care!
-	virtual epdf& _epdf()=0;
+	virtual epdf& _epdf() =0;
 
 	//! Destructor for future use;
@@ -267,7 +277,7 @@
 	virtual void condition ( const vec &val ) =0;
 	//! Default constructor
-	BMcond(RV &rv0):rvc(rv0){};
+	BMcond ( RV &rv0 ) :rvc ( rv0 ) {};
 	//! Destructor for future use
-	virtual ~BMcond(){};
+	virtual ~BMcond() {};
 	//! access function
 	const RV& _rvc() const {return rvc;}
