Changeset 181 for bdm/stat/emix.h

Show
Ignore:
Timestamp:
10/15/08 19:11:17 (16 years ago)
Author:
smidl
Message:

Regenerated doc

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/emix.h

    r178 r181  
    4040public: 
    4141        //!Default constructor 
    42         emix (const RV &rv ) : epdf ( rv ) {}; 
     42        emix ( const RV &rv ) : epdf ( rv ) {}; 
    4343        //! Set weights \c w and components \c Coms , Coms are not copied! 
    4444        void set_parameters ( const vec &w, const Array<epdf*> &Coms, bool copy=true ); 
     
    6060        //! returns a pointer to the internal mean value. Use with Care! 
    6161        vec& _w() {return w;} 
    62         virtual ~emix(){if (destroyComs){for(int i=0;i<Coms.length();i++){delete Coms(i);}}} 
     62        virtual ~emix() {if ( destroyComs ) {for ( int i=0;i<Coms.length();i++ ) {delete Coms ( i );}}} 
    6363        //! Auxiliary function for taking ownership of the Coms() 
    64         void ownComs(){destroyComs=true;} 
     64        void ownComs() {destroyComs=true;} 
    6565}; 
    6666 
     
    7575class mprod: public compositepdf, public mpdf { 
    7676protected: 
    77         // pointers to epdfs 
     77        //! pointers to epdfs - shortcut to mpdfs()._epdf() 
    7878        Array<epdf*> epdfs; 
    7979        //! Indeces of rvc in common rvc 
    80         Array<ivec> rvcinds; 
     80        Array<ivec> rvcsinrvc; 
     81        //! Indeces of common rvc in rvcs 
     82        Array<ivec> rvcinrvcs; 
    8183public: 
    8284        /*!\brief Constructor from list of mFacs, 
    83         Additional parameter overlap is left for future use. Do not set to true for mprod. 
    8485        */ 
    85         mprod ( Array<mpdf*> mFacs): compositepdf(mFacs), mpdf(getrv(true),RV()), epdfs(n), rvcinds(n) 
    86         {       setrvc(rv,rvc); 
    87                 setrvcinrv(rvc,rvcinds); 
    88                 setindices(rv);  
    89         for(int i=0;i<n;i++){epdfs(i)=&(mpdfs(i)->_epdf());} 
    90         }; 
    91  
    92         double evalpdflog ( const vec &val ) const { 
     86        mprod ( Array<mpdf*> mFacs ) : compositepdf ( mFacs ), mpdf ( getrv ( true ),RV() ), epdfs ( n ), rvcsinrvc ( n ) { 
     87                setrvc ( rv,rvc ); 
     88                setindices ( rv ); 
     89                for ( int i = 0;i < n;i++ ) { 
     90                        // find ith rvc in common rv 
     91                        rvcsinrvc ( i ) = mpdfs ( i )->_rvc().dataind ( rvc ); 
     92                        //and vice-versa 
     93                        rvcinrvcs ( i ) = rvc.dataind ( mpdfs ( i )->_rvc() ); 
     94                } 
     95 
     96                for ( int i=0;i<n;i++ ) { 
     97                        epdfs ( i ) =& ( mpdfs ( i )->_epdf() ); 
     98                } 
     99        }; 
     100 
     101        double evalcond ( const vec &val, const vec &cond ) const { 
    93102                int i; 
    94103                double res = 0.0; 
     104                vec condi; 
    95105                for ( i = n - 1;i > 0;i++ ) { 
    96                         if ( rvcinds ( i ).length() > 0 ) 
    97                                 {mpdfs ( i )->condition ( val ( rvcinds ( i ) ) );} 
     106                        if ( ( rvcsinrvc ( i ).length() > 0 ) || ( rvcsinrv ( i ).length() > 0 ) ) { 
     107                                condi = zeros ( rvcsinrvc ( i ).length() +rvcsinrv ( i ).length() ); 
     108                                //copy part of the rvc into condi 
     109                                set_subvector ( condi, rvcinrvcs ( i ), get_vec ( cond,rvcsinrvc ( i ) ) ); 
     110                                //copy part of the rv into condi 
     111                                set_subvector ( condi, rvinrvcs ( i ), get_vec ( val,rvcsinrv ( i ) ) ); 
     112                                mpdfs ( i )->condition ( condi ); 
     113                        } 
    98114                        // add logarithms 
    99115                        res += epdfs ( i )->evalpdflog ( val ( rvsinrv ( i ) ) ); 
     
    107123                ll = 0; 
    108124                for ( int i = ( n - 1 );i >= 0;i-- ) { 
    109                         if (( rvcinds ( i ).length() > 0 )||( rvcsinrv ( i ).length() > 0 )) { 
    110                                 condi = zeros ( rvcsinrv(i).length() + rvcinds(i).length() ); 
     125                        if ( ( rvcsinrvc ( i ).length() > 0 ) || ( rvcsinrv ( i ).length() > 0 ) ) { 
     126                                condi = zeros ( rvcsinrv ( i ).length() + rvcsinrvc ( i ).length() ); 
    111127                                // copy data in condition 
    112                                 set_subvector ( condi,rvcinds ( i ), cond ); 
     128                                set_subvector ( condi,rvcsinrvc ( i ), cond ); 
    113129                                // copy data in already generated sample 
    114                                 set_subvector ( condi,rvinrvcs ( i ), get_vec(smp,rvcsinrv(i)) ); 
     130                                set_subvector ( condi,rvinrvcs ( i ), get_vec ( smp,rvcsinrv ( i ) ) ); 
    115131 
    116132                                mpdfs ( i )->condition ( condi ); 
     
    169185                double tmp=0; 
    170186                for ( int i=0;i<epdfs.length();i++ ) { 
    171                         tmp+=epdfs(i)->evalpdflog(val(rvinds(i))); 
     187                        tmp+=epdfs ( i )->evalpdflog ( val ( rvinds ( i ) ) ); 
    172188                } 
    173189                return tmp; 
    174190        } 
    175191        //!access function 
    176         const epdf* operator () (int i) const {it_assert_debug(i<epdfs.length(),"wrong index");return epdfs(i);} 
     192        const epdf* operator () ( int i ) const {it_assert_debug ( i<epdfs.length(),"wrong index" );return epdfs ( i );} 
    177193}; 
    178194