root/libEF.h @ 8

Revision 8, 2.4 kB (checked in by smidl, 16 years ago)

Kalmany funkci, PF nefunkci

  • Property svn:eol-style set to native
Line 
1/*!
2  \file
3  \brief Probability distributions for Exponential Family models.
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 EF_H
14#define EF_H
15
16#include <itpp/itbase.h>
17//#include <std>
18
19using namespace itpp;
20
21/*!
22* \brief General conjugate exponential family posterior density.
23
24* More?...
25*/
26class eEF :public epdf {
27
28public:
29        virtual void tupdate( double phi, mat &vbar, double nubar ){};
30        virtual void dupdate( mat &v,double nu=1.0 ){};
31};
32
33class mEF :public mpdf {
34
35public:
36
37};
38
39/*!
40* \brief General exponential family density
41
42* More?...
43*/
44template<class sq_T>
45class enorm : public eEF {
46        vec mu;
47        sq_T R;
48public:
49        enorm( RV &rv, vec &mu, sq_T &R );
50        enorm();
51        void tupdate( double phi, mat &vbar, double nubar );
52        void dupdate( mat &v,double nu=1.0 );
53        vec sample();
54        double eval( const vec &val );
55
56};
57
58/*!
59 \brief
60*/
61template<class sq_T>
62class mlnorm : public mEF {
63        enorm<sq_T> epdf;
64        mat A;
65public:
66        //! Constructor
67        mlnorm( RV &rv,RV &rvc, mat &A, sq_T &R );
68        //!Generate one sample of the posterior
69        vec samplecond( vec &cond, double &lik );
70        mat samplecond( vec &cond, vec &lik, int n );
71        void condition( vec &cond );
72};
73
74////////////////////////
75
76template<class sq_T>
77enorm<sq_T>::enorm( RV &rv, vec &mu0, sq_T &R0 ) {
78        mu = mu0;
79        R = R0;
80};
81
82template<class sq_T>
83void enorm<sq_T>::dupdate( mat &v, double nu ) {
84        //
85};
86
87template<class sq_T>
88void enorm<sq_T>::tupdate( double phi, mat &vbar, double nubar ) {
89        //
90};
91
92template<class sq_T>
93vec enorm<sq_T>::sample() {
94        //
95};
96
97template<class sq_T>
98double enorm<sq_T>::eval( const vec &val ) {
99        //
100};
101
102
103template<class sq_T>
104enorm<sq_T>::enorm() {};
105
106template<class sq_T>
107mlnorm<sq_T>::mlnorm( RV &rv,RV &rvc, mat &A, sq_T &R ) {
108        int dim = rv.length();
109        vec mu( dim );
110
111        epdf = enorm<sq_T>( rv,mu,R );
112}
113
114template<class sq_T>
115vec mlnorm<sq_T>::samplecond( vec &cond, double &lik ) {
116        this->condition( cond );
117        vec smp = epdf.sample();
118        lik = epdf.eval(smp);
119        return smp;
120}
121
122template<class sq_T>
123mat mlnorm<sq_T>::samplecond( vec &cond, vec &lik, int n ) {
124        int i;
125        int dim = rv.length();
126        mat Smp( dim,n );
127        vec smp( dim);
128        this->condition( cond );
129        for ( i=0; i<dim; i++ ) {
130                smp = epdf.sample();
131                lik(i) = epdf.eval(smp);
132                Smp.set_col( i ,smp);
133        }
134        return Smp;
135}
136
137template<class sq_T>
138void mlnorm<sq_T>::condition( vec &cond) {
139}
140
141#endif //EF_H
Note: See TracBrowser for help on using the browser.