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 | //! Class representing variables, most often random variables |
---|
22 | class RV { |
---|
23 | int len; |
---|
24 | ivec ids; |
---|
25 | ivec sizes; |
---|
26 | ivec times; |
---|
27 | ivec obs; |
---|
28 | Array<std::string> names; |
---|
29 | |
---|
30 | public: |
---|
31 | //! Full constructor which is called by the others |
---|
32 | RV(ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs); |
---|
33 | //! default constructor |
---|
34 | RV(ivec ids); |
---|
35 | friend std::ostream &operator<<(std::ostream &os, const RV &rv); |
---|
36 | }; |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | |
---|
41 | //! Class representing function of variables |
---|
42 | class fnc { |
---|
43 | RV rv; |
---|
44 | }; |
---|
45 | |
---|
46 | //! Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities. |
---|
47 | class BM { |
---|
48 | public: |
---|
49 | //! Incremental Bayes rule |
---|
50 | void bayes(vec dt); |
---|
51 | //! Batch Bayes rule (columns of Dt are observations) |
---|
52 | virtual void bayes(mat Dt); |
---|
53 | }; |
---|
54 | |
---|
55 | //! Probability density function with numerical statistics, e.g. posterior density. |
---|
56 | class epdf { |
---|
57 | RV rv; |
---|
58 | public: |
---|
59 | //! Returns the required moment of the epdf |
---|
60 | virtual vec moment(const int order = 1); |
---|
61 | }; |
---|
62 | |
---|
63 | //! Conditional probability density, e.g. modeling some dependencies. |
---|
64 | class mpdf { |
---|
65 | //! modeled random variable |
---|
66 | RV rv; |
---|
67 | //! random variable in condition |
---|
68 | RV rvc; |
---|
69 | public: |
---|
70 | |
---|
71 | //! Returns the required moment of the epdf |
---|
72 | virtual fnc moment(const int order = 1); |
---|
73 | }; |
---|
74 | |
---|
75 | #endif // BM_H |
---|