Changeset 693 for library/bdm/stat/emix.h
- Timestamp:
- 11/02/09 17:27:29 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/stat/emix.h
r675 r693 35 35 At present the only supported operation is evallogcond(). 36 36 */ 37 class mratio: public mpdf {37 class mratio: public pdf { 38 38 protected: 39 //! Nominator in the form of mpdf39 //! Nominator in the form of pdf 40 40 const epdf* nom; 41 41 … … 50 50 //!Default constructor. By default, the given epdf is not copied! 51 51 //! It is assumed that this function will be used only temporarily. 52 mratio ( const epdf* nom0, const RV &rv, bool copy = false ) : mpdf ( ), dl ( ) {52 mratio ( const epdf* nom0, const RV &rv, bool copy = false ) : pdf ( ), dl ( ) { 53 53 // adjust rv and rvc 54 54 … … 178 178 //! Update already existing marginal density \c target 179 179 void marginal ( const RV &rv, emix &target ) const; 180 shared_ptr< mpdf> condition ( const RV &rv ) const;180 shared_ptr<pdf> condition ( const RV &rv ) const; 181 181 182 182 //Access methods … … 283 283 Note that 284 284 */ 285 class mprod: public mpdf {285 class mprod: public pdf { 286 286 private: 287 Array<shared_ptr< mpdf> > mpdfs;288 289 //! Data link for each mpdfs287 Array<shared_ptr<pdf> > pdfs; 288 289 //! Data link for each pdfs 290 290 Array<shared_ptr<datalink_m2m> > dls; 291 291 … … 300 300 /*!\brief Constructor from list of mFacs 301 301 */ 302 mprod ( const Array<shared_ptr< mpdf> > &mFacs ) {302 mprod ( const Array<shared_ptr<pdf> > &mFacs ) { 303 303 set_elements ( mFacs ); 304 304 } 305 //! Set internal \c mpdfs from given values306 void set_elements (const Array<shared_ptr< mpdf> > &mFacs );305 //! Set internal \c pdfs from given values 306 void set_elements (const Array<shared_ptr<pdf> > &mFacs ); 307 307 308 308 double evallogcond ( const vec &val, const vec &cond ) { 309 309 int i; 310 310 double res = 0.0; 311 for ( i = mpdfs.length() - 1; i >= 0; i-- ) {312 /* if ( mpdfs(i)->_rvc().count() >0) {313 mpdfs ( i )->condition ( dls ( i )->get_cond ( val,cond ) );311 for ( i = pdfs.length() - 1; i >= 0; i-- ) { 312 /* if ( pdfs(i)->_rvc().count() >0) { 313 pdfs ( i )->condition ( dls ( i )->get_cond ( val,cond ) ); 314 314 } 315 315 // add logarithms 316 316 res += epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) );*/ 317 res += mpdfs ( i )->evallogcond (317 res += pdfs ( i )->evallogcond ( 318 318 dls ( i )->pushdown ( val ), 319 319 dls ( i )->get_cond ( val, cond ) … … 344 344 vec smpi; 345 345 // Hard assumption here!!! We are going backwards, to assure that samples that are needed from smp are already generated! 346 for ( int i = ( mpdfs.length() - 1 ); i >= 0; i-- ) {347 // generate contribution of this mpdf348 smpi = mpdfs(i)->samplecond(dls ( i )->get_cond ( smp , cond ));346 for ( int i = ( pdfs.length() - 1 ); i >= 0; i-- ) { 347 // generate contribution of this pdf 348 smpi = pdfs(i)->samplecond(dls ( i )->get_cond ( smp , cond )); 349 349 // copy contribution of this pdf into smp 350 350 dls ( i )->pushup ( smp, smpi ); … … 356 356 //! \code 357 357 //! { class='mprod'; 358 //! mpdfs = (..., ...); // list of mpdfs in the order of chain rule358 //! pdfs = (..., ...); // list of pdfs in the order of chain rule 359 359 //! } 360 360 //! \endcode 361 361 //!@} 362 362 void from_setting ( const Setting &set ) { 363 Array<shared_ptr< mpdf> > atmp; //temporary Array364 UI::get ( atmp, set, " mpdfs", UI::compulsory );363 Array<shared_ptr<pdf> > atmp; //temporary Array 364 UI::get ( atmp, set, "pdfs", UI::compulsory ); 365 365 set_elements ( atmp ); 366 366 } … … 460 460 461 461 462 /*! \brief Mixture of mpdfs with constant weights, all mpdfs are of equal RV and RVC462 /*! \brief Mixture of pdfs with constant weights, all pdfs are of equal RV and RVC 463 463 464 464 */ 465 class mmix : public mpdf {465 class mmix : public pdf { 466 466 protected: 467 //! Component ( mpdfs)468 Array<shared_ptr< mpdf> > Coms;467 //! Component (pdfs) 468 Array<shared_ptr<pdf> > Coms; 469 469 //!weights of the components 470 470 vec w; … … 474 474 475 475 //! Set weights \c w and components \c R 476 void set_parameters ( const vec &w0, const Array<shared_ptr< mpdf> > &Coms0 ) {476 void set_parameters ( const vec &w0, const Array<shared_ptr<pdf> > &Coms0 ) { 477 477 //!\todo check if all components are OK 478 478 Coms = Coms0;