| 1 | /*! |
|---|
| 2 | \file |
|---|
| 3 | \brief Bayesian Models (bm) that use Bayes rule to learn from observations |
|---|
| 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 BM_H |
|---|
| 14 | #define BM_H |
|---|
| 15 | |
|---|
| 16 | #include <itpp/itbase.h> |
|---|
| 17 | //#include <std> |
|---|
| 18 | |
|---|
| 19 | using namespace itpp; |
|---|
| 20 | |
|---|
| 21 | /*! |
|---|
| 22 | * \brief Class representing variables, most often random variables |
|---|
| 23 | |
|---|
| 24 | * More?... |
|---|
| 25 | */ |
|---|
| 26 | class RV { |
|---|
| 27 | int len; |
|---|
| 28 | ivec ids; |
|---|
| 29 | ivec sizes; |
|---|
| 30 | ivec times; |
|---|
| 31 | ivec obs; |
|---|
| 32 | Array<std::string> names; |
|---|
| 33 | |
|---|
| 34 | private: |
|---|
| 35 | void init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs ); |
|---|
| 36 | public: |
|---|
| 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 ); |
|---|
| 41 | //! Printing output e.g. for debugging. |
|---|
| 42 | friend std::ostream &operator<< ( std::ostream &os, const RV &rv ); |
|---|
| 43 | |
|---|
| 44 | //! Find indexes of another rv in self |
|---|
| 45 | ivec rvfind(RV rv2); |
|---|
| 46 | //! Add (concat) another variable to the current one |
|---|
| 47 | RV rvadd(RV rv2); |
|---|
| 48 | //! Subtract another variable from the current one |
|---|
| 49 | RV rvsubt(RV rv2); |
|---|
| 50 | //! Select only variables at indeces ind |
|---|
| 51 | RV rvsubselect(ivec ind); |
|---|
| 52 | //! Select only variables at indeces ind |
|---|
| 53 | RV operator()(ivec ind); |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | //! Class representing function of variables |
|---|
| 60 | class fnc { |
|---|
| 61 | RV rv; |
|---|
| 62 | }; |
|---|
| 63 | |
|---|
| 64 | //! Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities. |
|---|
| 65 | class BM { |
|---|
| 66 | public: |
|---|
| 67 | //! Incremental Bayes rule |
|---|
| 68 | void bayes ( vec dt ); |
|---|
| 69 | //! Batch Bayes rule (columns of Dt are observations) |
|---|
| 70 | virtual void bayes ( mat Dt ); |
|---|
| 71 | }; |
|---|
| 72 | |
|---|
| 73 | //! Probability density function with numerical statistics, e.g. posterior density. |
|---|
| 74 | class epdf { |
|---|
| 75 | RV rv; |
|---|
| 76 | public: |
|---|
| 77 | //! Returns the required moment of the epdf |
|---|
| 78 | virtual vec moment ( const int order = 1 ); |
|---|
| 79 | }; |
|---|
| 80 | |
|---|
| 81 | //! Conditional probability density, e.g. modeling some dependencies. |
|---|
| 82 | class mpdf { |
|---|
| 83 | //! modeled random variable |
|---|
| 84 | RV rv; |
|---|
| 85 | //! random variable in condition |
|---|
| 86 | RV rvc; |
|---|
| 87 | public: |
|---|
| 88 | |
|---|
| 89 | //! Returns the required moment of the epdf |
|---|
| 90 | virtual fnc moment ( const int order = 1 ); |
|---|
| 91 | }; |
|---|
| 92 | |
|---|
| 93 | #endif // BM_H |
|---|