Legend:
- Unmodified
- Added
- Removed
-
bdm/stat/emix.h
r175 r176 78 78 Additional parameter overlap is left for future use. Do not set to true for mprod. 79 79 */ 80 mprod ( Array<mpdf*> mFacs): compositepdf(mFacs), mpdf(getrv(true),RV()), rvcinds(n), epdfs(n)80 mprod ( Array<mpdf*> mFacs): compositepdf(mFacs), mpdf(getrv(true),RV()), epdfs(n), rvcinds(n) 81 81 { setrvc(rv,rvc); 82 82 setrvcinrv(rvc,rvcinds); -
bdm/stat/libBM.cpp
r175 r176 91 91 // } 92 92 93 RV RV::subselect ( ivecind ) const {93 RV RV::subselect (const ivec &ind ) const { 94 94 RV ret; 95 95 ret.init ( ids ( ind ), names ( to_Arr ( ind ) ), sizes ( ind ), times ( ind ) ); … … 99 99 void RV::t ( int delta ) { times += delta;} 100 100 101 RV RV::operator() ( ivecind ) const {101 RV RV::operator() (const ivec &ind ) const { 102 102 RV ret; 103 103 if ( ind.length() >0 ) { … … 140 140 } 141 141 142 ivec RV::dataind ( RVrv2 ) const {142 ivec RV::dataind (const RV &rv2 ) const { 143 143 ivec res ( 0 ); 144 144 if ( rv2.count()>0 ) { … … 155 155 } 156 156 157 RV RV::subt ( const RV rv2 ) const {157 RV RV::subt ( const RV &rv2 ) const { 158 158 ivec res = this->findself ( rv2 ); // nonzeros 159 159 ivec valid = itpp::find ( res == -1 ); //-1 => value not found => it remains -
bdm/stat/libBM.h
r175 r176 80 80 bool add ( const RV &rv2 ); 81 81 //! Subtract another variable from the current one 82 RV subt ( const RV rv2 ) const;82 RV subt ( const RV &rv2 ) const; 83 83 //! Select only variables at indeces ind 84 RV subselect ( ivecind ) const;84 RV subselect ( const ivec &ind ) const; 85 85 //! Select only variables at indeces ind 86 RV operator() ( ivecind ) const;86 RV operator() ( const ivec &ind ) const; 87 87 //! Shift \c time shifted by delta. 88 88 void t ( int delta ); … … 90 90 str tostr() const; 91 91 //! generate indeces into \param crv data vector that form data vector of self. 92 ivec dataind( RVcrv) const;92 ivec dataind(const RV &crv) const; 93 93 94 94 //!access function … … 103 103 //!access function 104 104 std::string name ( int at ) {return names ( at );}; 105 106 //!access function 107 void set_id ( int at, int id0 ) {ids ( at )=id0;}; 108 //!access function 109 void set_size ( int at, int size0 ) {sizes ( at )=size0; tsize=sum(sizes);}; 110 //!access function 111 void set_time ( int at, int time0 ) {times ( at )=time0;}; 112 105 113 //!Assign unused ids to this rv 106 114 void newids(); … … 160 168 161 169 //! Compute log-probability of multiple values argument \c val 162 virtual vec evalpdflog ( const mat &Val ) const {170 virtual vec evalpdflog_m ( const mat &Val ) const { 163 171 vec x ( Val.cols() ); 164 172 for ( int i=0;i<Val.cols();i++ ) {x ( i ) =evalpdflog( Val.get_col(i) ) ;} … … 318 326 //! I.e. marginal likelihood of the data with the posterior integrated out. 319 327 virtual double logpred(const vec &dt)const{it_error("Not implemented");return 0.0;} 328 //! Matrix version of logpred 329 vec logpred_m(const mat &dt)const{vec tmp(dt.cols());for(int i=0;i<dt.cols();i++){tmp(i)=logpred(dt.get_col(i));}return tmp;} 320 330 321 331 //! Destructor for future use; -
bdm/stat/libEF.h
r173 r176 91 91 void bayes ( const vec &dt ); 92 92 //!Flatten the posterior 93 virtual void flatten ( BMEF * B ) {it_error ( "Not implemented" );}93 virtual void flatten ( BMEF * B ) {it_error ( "Not implemented" );} 94 94 }; 95 95 … … 206 206 vec sample() const {it_error ( "Not implemented" );return vec_1 ( 0.0 );}; 207 207 vec mean() const {return beta/sum ( beta );}; 208 //! In this instance, val = [theta, r]. For multivariate instances, it is stored columnwise val = [theta_1 theta_2 ... r_1 r_2 ]208 //! In this instance, val is ... 209 209 double evalpdflog_nn ( const vec &val ) const {return ( beta-1 ) *log ( val );}; 210 210 double lognc () const { … … 216 216 //!access function 217 217 vec& _beta() {return beta;} 218 //!Set internal parameters 219 void set_parameters(const vec &beta0){ 220 if(beta0.length()!=beta.length()){ 221 it_assert_debug(rv.length()==1,"Undefined"); 222 rv.set_size(0,beta0.length()); 223 } 224 beta= beta0; 225 } 218 226 }; 219 227 … … 239 247 eDirich pred ( est ); 240 248 vec &beta = pred._beta(); 241 249 242 250 double lll; 243 251 if ( frg<1.0 ) … … 250 258 return pred.lognc()-lll; 251 259 } 252 void flatten ( BMEF* B ) {253 eDirich* E=dynamic_cast<eDirich*> (B);260 void flatten ( BMEF* B ) { 261 eDirich* E=dynamic_cast<eDirich*> ( B ); 254 262 // sum(beta) should be equal to sum(B.beta) 255 263 const vec &Eb=E->_beta(); 256 est.pow ( sum(beta)/sum(Eb) ); 264 est.pow ( sum ( beta ) /sum ( Eb ) ); 265 if ( evalll ) {last_lognc=est.lognc();} 266 } 267 const epdf& _epdf() const {return est;}; 268 void set_parameters ( const vec &beta0 ) { 269 est.set_parameters(beta0); 270 rv = est._rv(); 257 271 if(evalll){last_lognc=est.lognc();} 258 272 } 259 const epdf& _epdf() const {return est;};260 //!access funct261 273 }; 262 274