root/libBM.h @ 12

Revision 12, 2.9 kB (checked in by smidl, 16 years ago)

opravy v libDC (stale nefunkcni)

  • Property svn:eol-style set to native
RevLine 
[2]1/*!
[5]2  \file
3  \brief Bayesian Models (bm) that use Bayes rule to learn from observations
4  \author Vaclav Smidl.
[2]5
[5]6  -----------------------------------
7  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
8
9  Using IT++ for numerical operations
10  -----------------------------------
11*/
12
[2]13#ifndef BM_H
14#define BM_H
15
16#include <itpp/itbase.h>
17//#include <std>
18
19using namespace itpp;
20
[5]21/*!
22* \brief Class representing variables, most often random variables
23
24* More?...
25*/
[2]26class RV {
[12]27        int size,len;
[5]28        ivec ids;
29        ivec sizes;
30        ivec times;
31        ivec obs;
32        Array<std::string> names;
[2]33
[5]34private:
35        void init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs );
[2]36public:
[5]37        //! Full constructor which is called by the others
38        RV ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs );
39        //! default constructor
40        RV ( ivec ids );
[8]41        //! Empty constructor will be set later
42        RV ();
43       
[5]44        //! Printing output e.g. for debugging.
45        friend std::ostream &operator<< ( std::ostream &os, const RV &rv );
46
[8]47        //! Return length (number of scalars) of the RV.
[12]48        int count() {return size;}
49        //TODO why not inline and later??
50       
[5]51        //! Find indexes of another rv in self
[12]52        ivec find(RV rv2);
[5]53        //! Add (concat) another variable to the current one
[12]54        RV add(RV rv2);
[5]55        //! Subtract  another variable from the current one
[12]56        RV subt(RV rv2);
[5]57        //! Select only variables at indeces ind
[12]58        RV subselect(ivec ind);
[5]59        //! Select only variables at indeces ind
60        RV operator()(ivec ind);
[8]61        //! Generate new \c RV with \c time shifted by delta.
62        void t(int delta);
[2]63};
64
65
66
67
68//! Class representing function of variables
69class fnc {
[5]70        RV rv;
[2]71};
72
[4]73//! Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.
[2]74class BM {
75public:
[7]76        //!Logarithm of marginalized data likelihood.
77        double ll;
78
79        /*! \brief Incremental Bayes rule
80        @param dt vector of input data
81        @param evall If true, the filter will compute likelihood of the data record and store it in \c ll
82        */
83        virtual void bayes ( const vec &dt, bool evall=true ) = 0;
[5]84        //! Batch Bayes rule (columns of Dt are observations)
[7]85        void bayes ( mat Dt );
[2]86};
87
[4]88//! Probability density function with numerical statistics, e.g. posterior density.
[2]89class epdf {
[5]90        RV rv;
[2]91public:
[5]92        //! Returns the required moment of the epdf
[8]93//      virtual vec moment ( const int order = 1 );
94        //! Returns a sample from the density, $x \sim epdf(rv)$
95        virtual vec sample (){};
96        virtual double eval(const vec &val){};
[2]97};
98
[5]99//! Conditional probability density, e.g. modeling some dependencies.
[2]100class mpdf {
[5]101        //! modeled random variable
102        RV rv;
103        //! random variable in condition
104        RV rvc;
[2]105public:
106
[5]107        //! Returns the required moment of the epdf
[8]108//      virtual fnc moment ( const int order = 1 );
109        //! Returns a sample from the density conditioned on \c cond, $x \sim epdf(rv|cond)$
110        virtual vec samplecond (vec &cond, double lik){};
111        virtual void condition (vec &cond){};
[2]112};
113
[12]114
115
[2]116#endif // BM_H
Note: See TracBrowser for help on using the browser.