| 1 | #ifndef FASTGEM_BIRTHDEATHMCMC_HH |
| 2 | #define FASTGEM_BIRTHDEATHMCMC_HH |
| 3 | |
| 4 | #include <string> |
| 5 | #include <iostream> |
| 6 | |
| 7 | #include "fastGEM_BirthDeathProbs.hh" |
| 8 | #include "PRNG.hh" |
| 9 | #include "ReconciliationSampler.hh" |
| 10 | #include "StdMCMCModel.hh" |
| 11 | #include "Tree.hh" |
| 12 | |
| 13 | namespace beep |
| 14 | { |
| 15 | |
| 16 | // TODO: This MCMCModel will be replaced by an EdgeRateMCMC, eventually /bens |
| 17 | |
| 18 | class fastGEM_BirthDeathMCMC : public StdMCMCModel, |
| 19 | public fastGEM_BirthDeathProbs |
| 20 | { |
| 21 | public: |
| 22 | //------------------------------------------------------------- |
| 23 | // |
| 24 | // Construct/Destruct/Assign |
| 25 | // |
| 26 | //------------------------------------------------------------- |
| 27 | fastGEM_BirthDeathMCMC(MCMCModel& prior,Tree &S,unsigned noOfDiscrPoints, |
| 28 | std::vector<double>* discrPoints, Real birthRate, |
| 29 | Real deathRate, Real* topTime = 0); |
| 30 | ~fastGEM_BirthDeathMCMC(); |
| 31 | |
| 32 | |
| 33 | //------------------------------------------------------------- |
| 34 | // |
| 35 | // Interface |
| 36 | // |
| 37 | //------------------------------------------------------------- |
| 38 | void fixRates(); |
| 39 | void multiplySuggestionVariance(Real multiplier) |
| 40 | { |
| 41 | suggestion_variance = multiplier * (birth_rate+death_rate) / 2.0; |
| 42 | } |
| 43 | |
| 44 | MCMCObject suggestOwnState(); |
| 45 | void commitOwnState(); |
| 46 | void discardOwnState(); |
| 47 | std::string ownStrRep() const; |
| 48 | std::string ownHeader() const; |
| 49 | Probability updateDataProbability(); |
| 50 | |
| 51 | //------------------------------------------------------------- |
| 52 | // I/O |
| 53 | //------------------------------------------------------------- |
| 54 | friend std::ostream& operator<<(std::ostream &o, const fastGEM_BirthDeathMCMC& A); |
| 55 | std::string print() const; |
| 56 | |
| 57 | private: |
| 58 | // //------------------------------------------------------------- |
| 59 | // // |
| 60 | // // Implementation |
| 61 | // // |
| 62 | // //------------------------------------------------------------- |
| 63 | |
| 64 | // // Utility function for changing birth/death rates. |
| 65 | // // Returns a number in the interval [0.8, 1.25]. |
| 66 | // //------------------------------------------------------------- |
| 67 | // Real rateChange(); |
| 68 | |
| 69 | //------------------------------------------------------------- |
| 70 | // |
| 71 | // Attributes - none |
| 72 | // |
| 73 | //------------------------------------------------------------- |
| 74 | Real old_birth_rate; |
| 75 | Real old_death_rate; |
| 76 | bool estimateRates; |
| 77 | |
| 78 | //! The suggestion function uses a normal distribution around the current |
| 79 | //! value. For the proposal-ratios to function right, we need to keep the |
| 80 | //! variance to the distribution constant. This is a problem since we do not |
| 81 | //! know the location/scale of the distribution ahead of time. As a fix, we |
| 82 | //! store a variance initiated from the start values of dupl/loss rates. |
| 83 | Real suggestion_variance; |
| 84 | }; |
| 85 | }//end namespace beep |
| 86 | |
| 87 | |
| 88 | #endif |