477 | | // class mmix : public mpdf { |
478 | | // protected: |
479 | | // //! Component (epdfs) |
480 | | // Array<mpdf*> Coms; |
481 | | // |
482 | | // //!Internal epdf |
483 | | // emix iepdf; |
484 | | // |
485 | | // public: |
486 | | // //!Default constructor |
487 | | // mmix() : iepdf ( ) { |
488 | | // set_ep ( iepdf ); |
489 | | // } |
490 | | // |
491 | | // //! Set weights \c w and components \c R |
492 | | // void set_parameters ( const vec &w, const Array<mpdf*> &Coms ) { |
493 | | // Array<epdf*> Eps ( Coms.length() ); |
494 | | // |
495 | | // for ( int i = 0; i < Coms.length(); i++ ) { |
496 | | // Eps ( i ) = Coms ( i )->e(); |
497 | | // } |
498 | | // |
499 | | // iepdf->set_parameters ( w, Eps ); |
500 | | // } |
501 | | // |
502 | | // void condition ( const vec &cond ) { |
503 | | // for ( int i = 0; i < Coms.length(); i++ ) { |
504 | | // Coms ( i )->condition ( cond ); |
505 | | // } |
506 | | // }; |
507 | | // }; |
| 477 | class mmix : public mpdf { |
| 478 | protected: |
| 479 | //! Component (mpdfs) |
| 480 | Array<shared_ptr<mpdf> > Coms; |
| 481 | //!weights of the components |
| 482 | vec w; |
| 483 | //! dummy epdfs |
| 484 | epdf dummy_epdf; |
| 485 | public: |
| 486 | //!Default constructor |
| 487 | mmix() : Coms(0), dummy_epdf() { set_ep(dummy_epdf); } |
| 488 | |
| 489 | //! Set weights \c w and components \c R |
| 490 | void set_parameters ( const vec &w0, const Array<shared_ptr<mpdf> > &Coms0 ) { |
| 491 | //!\TODO check if all components are OK |
| 492 | Coms = Coms0; |
| 493 | w=w0; |
| 494 | |
| 495 | set_rv(Coms(0)->_rv()); |
| 496 | set_rvc(Coms(0)->_rvc()); |
| 497 | } |
| 498 | double evallogcond (const vec &dt, const vec &cond) { |
| 499 | double ll=0.0; |
| 500 | for (int i=0;i<Coms.length();i++){ |
| 501 | ll+=Coms(i)->evallogcond(dt,cond); |
| 502 | } |
| 503 | return ll; |
| 504 | } |
| 505 | |
| 506 | vec samplecond (const vec &cond); |
| 507 | |
| 508 | }; |