Legend:
- Unmodified
- Added
- Removed
-
libBM.h
r4 r5 1 1 /*! 2 *\file3 *\brief Bayesian Models (bm) that use Bayes rule to learn from observations4 *\author Vaclav Smidl.5 * 6 *-----------------------------------7 *BDM++ - C++ library for Bayesian Decision Making under Uncertainty8 * 9 *Using IT++ for numerical operations10 *-----------------------------------11 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 12 13 13 #ifndef BM_H … … 19 19 using namespace itpp; 20 20 21 //! Class representing variables, most often random variables 21 /*! 22 * \brief Class representing variables, most often random variables 23 24 * More?... 25 */ 22 26 class RV { 23 int len;24 ivec ids;25 ivec sizes;26 ivec times;27 ivec obs;28 Array<std::string> names;27 int len; 28 ivec ids; 29 ivec sizes; 30 ivec times; 31 ivec obs; 32 Array<std::string> names; 29 33 34 private: 35 void init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs ); 30 36 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); 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); 36 54 }; 37 55 … … 41 59 //! Class representing function of variables 42 60 class fnc { 43 RV rv;61 RV rv; 44 62 }; 45 63 … … 47 65 class BM { 48 66 public: 49 //! Incremental Bayes rule50 void bayes(vec dt);51 //! Batch Bayes rule (columns of Dt are observations)52 virtual void bayes(mat Dt);67 //! Incremental Bayes rule 68 void bayes ( vec dt ); 69 //! Batch Bayes rule (columns of Dt are observations) 70 virtual void bayes ( mat Dt ); 53 71 }; 54 72 55 73 //! Probability density function with numerical statistics, e.g. posterior density. 56 74 class epdf { 57 RV rv;75 RV rv; 58 76 public: 59 //! Returns the required moment of the epdf60 virtual vec moment(const int order = 1);77 //! Returns the required moment of the epdf 78 virtual vec moment ( const int order = 1 ); 61 79 }; 62 80 63 //! Conditional probability density, e.g. modeling some dependencies. 81 //! Conditional probability density, e.g. modeling some dependencies. 64 82 class mpdf { 65 //! modeled random variable66 RV rv;67 //! random variable in condition68 RV rvc;83 //! modeled random variable 84 RV rv; 85 //! random variable in condition 86 RV rvc; 69 87 public: 70 88 71 //! Returns the required moment of the epdf72 virtual fnc moment(const int order = 1);89 //! Returns the required moment of the epdf 90 virtual fnc moment ( const int order = 1 ); 73 91 }; 74 92