root/bdm/estim/merger.h @ 182

Revision 182, 2.0 kB (checked in by smidl, 16 years ago)

compilation error!

Line 
1/*!
2  \file
3  \brief Mergers for combination of pdfs
4  \author Vaclav Smidl.
5
6  -----------------------------------
7  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
8
9  Using IT++ for numerical operations
10  -----------------------------------
11*/
12
13#ifndef MER_H
14#define MER_H
15
16#include <itpp/itbase.h>
17#include "mixef.h"
18
19using namespace itpp;
20using std::string;
21
22/*!
23@brief Function for general combination of pdfs
24
25Mixtures of Gaussian densities are used internally. Switching to other densities should be trivial.
26*/
27
28class merger : public compositepdf, public epdf {
29protected:
30        //!Internal mixture of EF models
31        MixEF Mix;
32        //!Number of samples used in approximation
33        int Ns;
34        //!Number of components in a mixture
35        int Nc;
36        //!Prior on the log-normal merging model
37        double beta;
38public:
39//!Default constructor
40        merger ( const Array<mpdf*> &S ) :
41                        compositepdf ( S ), epdf ( getrv ( false ) ),
42                        Mix ( Array<BMEF*> ( 0 ),vec ( 0 ) )
43        {setindices(rv); beta=2.0; Ns=100; Nc=10;}
44        //! Set internal parameters used in approximation
45        void set_parameters ( double beta0, int Ns0, int Nc0 ) {        beta=beta0;Ns=Ns0;Nc=Nc0;}
46        //!Initialize the proposal density. This function must be called before merge()!
47        void init() {
48                Array<vec> Smps ( n );
49                //Gibbs sampling
50                for ( int i=0;i<n;i++ ) {Smps ( i ) =zeros ( 0 );}
51        }
52        //!Create a mixture density using known proposal
53        void merge ( const epdf* g0 );
54        //!Create a mixture density, make sure to call init() before the first call
55        void merge () {merge ( & ( Mix._epdf() ) );};
56
57        //! Merge log-likelihood values
58        vec lognorm_merge ( mat &lW );
59        //! sample from merged density
60        //! weight w is a
61        vec sample ( )const { return Mix._epdf().sample();}
62        double evalpdflog ( const vec &dt ) const{ 
63                vec dtf=ones(dt.length()+1);   
64                dtf.set_subvector(0,dt); 
65                return Mix.logpred ( dtf );}
66        vec mean()const {return Mix._epdf().mean();}
67        //! for future use
68        virtual ~merger() {};
69       
70        //! Access function
71        MixEF& _Mix() {return Mix;}
72};
73
74
75
76#endif // MER_H
Note: See TracBrowser for help on using the browser.