| 1 | /*! |
|---|
| 2 | \file |
|---|
| 3 | \brief Support for testing descendants of epdf. |
|---|
| 4 | \author Vaclav Barta. |
|---|
| 5 | |
|---|
| 6 | ----------------------------------- |
|---|
| 7 | BDM++ - C++ library for Bayesian Decision Making under Uncertainty |
|---|
| 8 | |
|---|
| 9 | Using IT++ for numerical operations |
|---|
| 10 | ----------------------------------- |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | #ifndef EPDF_HARNESS_H |
|---|
| 14 | #define EPDF_HARNESS_H |
|---|
| 15 | |
|---|
| 16 | #define BDMLIB // not an ideal way to prevent double registration of UI factories... |
|---|
| 17 | |
|---|
| 18 | #include "bdmroot.h" |
|---|
| 19 | #include "itpp_ext.h" |
|---|
| 20 | #include "shared_ptr.h" |
|---|
| 21 | #include "base/bdmbase.h" |
|---|
| 22 | #include "base/user_info.h" |
|---|
| 23 | #include "stat/emix.h" |
|---|
| 24 | |
|---|
| 25 | namespace bdm { |
|---|
| 26 | |
|---|
| 27 | class epdf_harness : public root { |
|---|
| 28 | private: |
|---|
| 29 | shared_ptr<epdf> hepdf; |
|---|
| 30 | vec mean; |
|---|
| 31 | vec variance; |
|---|
| 32 | mat support; |
|---|
| 33 | ivec nbins; |
|---|
| 34 | int nsamples; |
|---|
| 35 | mat R; |
|---|
| 36 | shared_ptr<RV> mrv; |
|---|
| 37 | double tolerance; |
|---|
| 38 | |
|---|
| 39 | public: |
|---|
| 40 | static void test_config ( const char *config_file_name ); |
|---|
| 41 | |
|---|
| 42 | epdf_harness() : nsamples ( 1000 ), tolerance ( 0.1 ) { } |
|---|
| 43 | |
|---|
| 44 | virtual void test ( const char *config_name, int idx ); |
|---|
| 45 | |
|---|
| 46 | void from_setting ( const Setting &set ); |
|---|
| 47 | |
|---|
| 48 | protected: |
|---|
| 49 | epdf *get_epdf() { |
|---|
| 50 | return hepdf.get(); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | double get_tolerance() const { |
|---|
| 54 | return tolerance; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | private: |
|---|
| 58 | // assumes support is valid |
|---|
| 59 | void check_support_mean(); |
|---|
| 60 | |
|---|
| 61 | // assumes support is valid |
|---|
| 62 | void check_support_integral(); |
|---|
| 63 | |
|---|
| 64 | // assumes R is valid - it probably shouldn't, but calling it |
|---|
| 65 | // unconditionally leads to a lot of not implemented |
|---|
| 66 | // functions... |
|---|
| 67 | void check_sample_mean(); |
|---|
| 68 | |
|---|
| 69 | // assumes R is valid |
|---|
| 70 | void check_covariance(); |
|---|
| 71 | |
|---|
| 72 | // assumes marginal_rv is valid |
|---|
| 73 | void check_cond_mean( mprod &mep ); |
|---|
| 74 | |
|---|
| 75 | // assumes marginal_rv and R are valid |
|---|
| 76 | void check_cond_covariance( mprod &mep ); |
|---|
| 77 | }; |
|---|
| 78 | |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | #endif |
|---|