Changeset 175 for bdm/stat/emix.h
- Timestamp:
- 10/09/08 11:32:11 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
bdm/stat/emix.h
r170 r175 68 68 Note that 69 69 */ 70 class mprod: public mpdf { 71 protected: 72 // 73 int n; 70 class mprod: public compositepdf, public mpdf { 71 protected: 74 72 // pointers to epdfs 75 73 Array<epdf*> epdfs; 76 Array<mpdf*> mpdfs;77 //78 //! Indeces of rvs in common rv79 Array<ivec> rvinds;80 //! Indeces of rvc in common rv81 Array<ivec> rvcinrv;82 74 //! Indeces of rvc in common rvc 83 75 Array<ivec> rvcinds; 84 // //! Indicate independence of its factors85 // bool independent;86 // //! Indicate internal creation of mpdfs which must be destroyed87 // bool intermpdfs;88 76 public: 89 77 /*!\brief Constructor from list of mFacs, 90 78 Additional parameter overlap is left for future use. Do not set to true for mprod. 91 79 */ 92 mprod ( Array<mpdf*> mFacs, bool overlap=false ); 80 mprod ( Array<mpdf*> mFacs): compositepdf(mFacs), mpdf(getrv(true),RV()), rvcinds(n), epdfs(n) 81 { setrvc(rv,rvc); 82 setrvcinrv(rvc,rvcinds); 83 setindices(rv); 84 for(int i=0;i<n;i++){epdfs(i)=&(mpdfs(i)->_epdf());} 85 }; 93 86 94 87 double evalpdflog ( const vec &val ) const { … … 99 92 {mpdfs ( i )->condition ( val ( rvcinds ( i ) ) );} 100 93 // add logarithms 101 res += epdfs ( i )->evalpdflog ( val ( rv inds( i ) ) );94 res += epdfs ( i )->evalpdflog ( val ( rvsinrv ( i ) ) ); 102 95 } 103 96 return res; … … 110 103 for ( int i = ( n - 1 );i >= 0;i-- ) { 111 104 if ( rvcinds ( i ).length() > 0 ) { 112 condi = zeros ( rvc inrv.length() + rvcinds.length() );105 condi = zeros ( rvcsinrv.length() + rvcinds.length() ); 113 106 // copy data in condition 114 107 set_subvector ( condi,rvcinds ( i ), cond ); 115 108 // copy data in already generated sample 116 set_subvector ( condi,rvc inrv ( i ), smp );109 set_subvector ( condi,rvcsinrv ( i ), smp ); 117 110 118 111 mpdfs ( i )->condition ( condi ); … … 120 113 smpi = epdfs ( i )->sample(); 121 114 // copy contribution of this pdf into smp 122 set_subvector ( smp,rv inds( i ), smpi );115 set_subvector ( smp,rvsinrv ( i ), smpi ); 123 116 // add ith likelihood contribution 124 117 ll+=epdfs ( i )->evalpdflog ( smpi );