Changeset 5 for libBM.h

Show
Ignore:
Timestamp:
01/18/08 18:43:51 (16 years ago)
Author:
smidl
Message:

RV

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • libBM.h

    r4 r5  
    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  */ 
     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*/ 
    1212 
    1313#ifndef BM_H 
     
    1919using namespace itpp; 
    2020 
    21 //! Class representing variables, most often random variables 
     21/*! 
     22* \brief Class representing variables, most often random variables 
     23 
     24* More?... 
     25*/ 
    2226class 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; 
    2933 
     34private: 
     35        void init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs ); 
    3036public: 
    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); 
    3654}; 
    3755 
     
    4159//! Class representing function of variables 
    4260class fnc { 
    43 RV rv; 
     61        RV rv; 
    4462}; 
    4563 
     
    4765class BM { 
    4866public: 
    49 //! Incremental Bayes rule 
    50 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 ); 
    5371}; 
    5472 
    5573//! Probability density function with numerical statistics, e.g. posterior density. 
    5674class epdf { 
    57 RV rv; 
     75        RV rv; 
    5876public: 
    59 //! Returns the required moment of the epdf 
    60 virtual vec moment(const int order = 1); 
     77        //! Returns the required moment of the epdf 
     78        virtual vec moment ( const int order = 1 ); 
    6179}; 
    6280 
    63 //! Conditional probability density, e.g. modeling some dependencies.  
     81//! Conditional probability density, e.g. modeling some dependencies. 
    6482class mpdf { 
    65 //! modeled random variable 
    66 RV rv; 
    67 //! random variable in condition 
    68 RV rvc; 
     83        //! modeled random variable 
     84        RV rv; 
     85        //! random variable in condition 
     86        RV rvc; 
    6987public: 
    7088 
    71 //! Returns the required moment of the epdf 
    72 virtual fnc moment(const int order = 1); 
     89        //! Returns the required moment of the epdf 
     90        virtual fnc moment ( const int order = 1 ); 
    7391}; 
    7492