00001 #ifndef __BCENGINEMCMC__H 00002 #define __BCENGINEMCMC__H 00003 00004 /*! 00005 * \class BCEngineMCMC 00006 * \brief An engine class for Markov Chain Monte Carlo 00007 * \author Daniel Kollar 00008 * \author Kevin Kröninger 00009 * \version 1.0 00010 * \date 08.2008 00011 * \detail This class represents an engine class for Markov Chain 00012 * Monte Carlo (MCMC). One or more chains can be defined 00013 * simultaneously. 00014 */ 00015 00016 /* 00017 * Copyright (C) 2008-2010, Daniel Kollar and Kevin Kroeninger. 00018 * All rights reserved. 00019 * 00020 * For the licensing terms see doc/COPYING. 00021 */ 00022 00023 // --------------------------------------------------------- 00024 00025 #include <vector> 00026 00027 // ROOT classes 00028 class TH1D; 00029 class TH2D; 00030 class TTree; 00031 class TRandom3; 00032 00033 // --------------------------------------------------------- 00034 00035 class BCEngineMCMC 00036 { 00037 00038 public: 00039 00040 /** \name Enumerators */ 00041 /* @{ */ 00042 00043 /** An enumerator for the status of a test. */ 00044 enum Precision{ kLow, kMedium, kHigh, kVeryHigh }; 00045 00046 /* @} */ 00047 /** \name Constructors and destructors */ 00048 /* @{ */ 00049 00050 /** 00051 * Default constructor. */ 00052 BCEngineMCMC(); 00053 00054 /** 00055 * Constructor. 00056 * @param n number of chains */ 00057 BCEngineMCMC(int n); 00058 00059 /** 00060 * Default copy constructor. */ 00061 BCEngineMCMC(const BCEngineMCMC & enginemcmc); 00062 00063 /** 00064 * Default destructor. */ 00065 virtual ~BCEngineMCMC(); 00066 00067 /* @} */ 00068 /** \name Assignment operators */ 00069 /* @{ */ 00070 00071 /** 00072 * Defaut assignment operator */ 00073 BCEngineMCMC & operator = (const BCEngineMCMC & engineMCMC); 00074 00075 /* @} */ 00076 /** \name Getters */ 00077 /* @{ */ 00078 00079 /* 00080 * @return number of parameters of the Markov chain */ 00081 int MCMCGetNParameters() 00082 { return fMCMCNParameters; }; 00083 00084 /* 00085 * @return number of Markov chains */ 00086 int MCMCGetNChains() 00087 { return fMCMCNChains; }; 00088 00089 /* 00090 * @return lag of the Markov chains */ 00091 int MCMCGetNLag() 00092 { return fMCMCNLag; }; 00093 00094 /* 00095 * @return number of iterations */ 00096 std::vector <int> MCMCGetNIterations() 00097 { return fMCMCNIterations; }; 00098 00099 /** 00100 * @return current iterations */ 00101 int MCMCGetCurrentIteration() 00102 { return fMCMCCurrentIteration; }; 00103 00104 /** 00105 * @return current chain index */ 00106 int MCMCGetCurrentChain() 00107 { return fMCMCCurrentChain; }; 00108 00109 /* 00110 * @return number of iterations needed for all chains to 00111 * converge simultaneously */ 00112 int MCMCGetNIterationsConvergenceGlobal() 00113 { return fMCMCNIterationsConvergenceGlobal; }; 00114 00115 /* 00116 * @return flag if converged or not */ 00117 bool MCMCGetFlagConvergenceGlobal() 00118 { return fMCMCFlagConvergenceGlobal; }; 00119 00120 /* 00121 * @return maximum number of iterations for a Markov chain */ 00122 int MCMCGetNIterationsMax() 00123 { return fMCMCNIterationsMax; }; 00124 00125 /* 00126 * @return number of iterations for a Markov chain */ 00127 int MCMCGetNIterationsRun() 00128 { return fMCMCNIterationsRun; }; 00129 00130 /* 00131 * @return minimum number of pre-run iterations for a Markov chain */ 00132 int MCMCGetNIterationsPreRunMin() 00133 { return fMCMCNIterationsPreRunMin; }; 00134 00135 /* 00136 * @return number of iterations after statistics update. */ 00137 int MCMCGetNIterationsUpdate() 00138 { return fMCMCNIterationsUpdate; }; 00139 00140 /* 00141 * @return maximum number of iterations after statistics update. */ 00142 int MCMCGetNIterationsUpdateMax() 00143 { return fMCMCNIterationsUpdateMax; }; 00144 00145 /* 00146 * @returns number of accepted trials for each chain */ 00147 std::vector <int> MCMCGetNTrialsTrue() 00148 { return fMCMCNTrialsTrue; }; 00149 00150 /* 00151 * @returns number of not-accepted trials for each chain */ 00152 std::vector <int> MCMCGetNTrialsFalse() 00153 { return fMCMCNTrialsFalse; }; 00154 00155 /* 00156 * @return mean value of the probability for each chain up to 00157 * the current iteration */ 00158 std::vector <double> MCMCGetprobMean() 00159 { return fMCMCprobMean; }; 00160 00161 /* 00162 * @return mean value of the probability for each chain up to 00163 * the current iteration */ 00164 std::vector <double> MCMCGetVariance() 00165 { return fMCMCprobVar; }; 00166 00167 /* 00168 * @return scale factor for all parameters and chains */ 00169 std::vector <double> MCMCGetTrialFunctionScaleFactor() 00170 { return fMCMCTrialFunctionScaleFactor; }; 00171 00172 /* 00173 * @return scale factor for all parameters and achain. 00174 * @param ichain chain index */ 00175 std::vector <double> MCMCGetTrialFunctionScaleFactor(int ichain); 00176 00177 /* 00178 * @return scale factor for a parameter and a chain. 00179 * @param ichain chain index 00180 * @param ipar parameter index */ 00181 double MCMCGetTrialFunctionScaleFactor(int ichain, int ipar); 00182 00183 /* 00184 * @return current point of each Markov chain */ 00185 std::vector <double> MCMCGetx() 00186 { return fMCMCx; }; 00187 00188 /* 00189 * @param ichain index of the Markov chain 00190 * @return current point of the Markov chain */ 00191 std::vector <double> MCMCGetx(int ichain); 00192 00193 /* 00194 * @param ichain chain index 00195 * @param ipar parameter index 00196 * @return parameter of the Markov chain */ 00197 double MCMCGetx(int ichain, int ipar); 00198 00199 /* 00200 * @return log of the probability of the current points of each Markov chain */ 00201 std::vector <double> MCMCGetLogProbx() 00202 { return fMCMCprob; }; 00203 00204 /* 00205 * @return log of the probability of the current points of the Markov chain. 00206 * @param ichain chain index */ 00207 double MCMCGetLogProbx(int ichain); 00208 00209 /* 00210 * @return pointer to the phase of a run. */ 00211 int MCMCGetPhase() 00212 { return fMCMCPhase; }; 00213 00214 /* 00215 * @return pointer to the cycle of a pre-run. */ 00216 int MCMCGetCycle() 00217 { return fMCMCCycle; }; 00218 00219 /* 00220 * @return maximum points of each Markov chain */ 00221 std::vector <double> MCMCGetMaximumPoints() 00222 { return fMCMCxMax; }; 00223 00224 /* 00225 * @return maximum point of Markov chain 00226 * @param i The index of the Markov chain */ 00227 std::vector <double> MCMCGetMaximumPoint(int i); 00228 00229 /* 00230 * @return maximum (log) probability of each Markov chain */ 00231 std::vector <double> MCMCGetMaximumLogProb() 00232 { return fMCMCprobMax; }; 00233 00234 /* 00235 * @return flag which defined initial position */ 00236 int MCMCGetFlagInitialPosition() 00237 { return fMCMCFlagInitialPosition; }; 00238 00239 /* 00240 * @return R-value criterion */ 00241 double MCMCGetRValueCriterion() 00242 { return fMCMCRValueCriterion; }; 00243 00244 /* 00245 * @return R-value criterion for parameters */ 00246 double MCMCGetRValueParametersCriterion() 00247 { return fMCMCRValueParametersCriterion; }; 00248 00249 /* 00250 * @return R-value */ 00251 double MCMCGetRValue() 00252 { return fMCMCRValue; }; 00253 00254 /* 00255 * @return R-value for a parameter 00256 * @param i parameter index */ 00257 double MCMCGetRValueParameters(int i) 00258 { return fMCMCRValueParameters.at(i); }; 00259 00260 /* 00261 * @return the flag if MCMC has been performed or not */ 00262 bool MCMCGetFlagRun() 00263 { return fMCMCFlagRun; }; 00264 00265 /* 00266 * Rtrieve the tree containing the Markov chain. 00267 * @param i index of the Markov chain 00268 * @return pointer to the tree */ 00269 TTree * MCMCGetMarkovChainTree(int i) 00270 { return fMCMCTrees.at(i); }; 00271 00272 /* 00273 * Retrieve a histogram of the 1D marginalized distribution of a single parameter. 00274 * @param i index of the parameter 00275 * @return pointer to the histogram */ 00276 TH1D * MCMCGetH1Marginalized(int i); 00277 00278 /* 00279 * Retrieve a histogram of the 2D marginalized distribution for two parameters. 00280 * @param i index of the first parameter 00281 * @param j index of the second parameter 00282 * @return pointer to the histogram */ 00283 TH2D * MCMCGetH2Marginalized(int i, int j); 00284 00285 /* 00286 * Return the random number generator */ 00287 TRandom3 * MCMCGetTRandom3() 00288 { return fRandom; }; 00289 00290 /* @} */ 00291 /** \name Setters */ 00292 /* @{ */ 00293 00294 /* 00295 * Set the scale factors for the trial functions 00296 * @param scale a vector of doubles containing the scale factors */ 00297 void MCMCSetTrialFunctionScaleFactor(std::vector <double> scale) 00298 { fMCMCTrialFunctionScaleFactorStart = scale; }; 00299 00300 /* 00301 * Sets the number of Markov chains which are run in parallel. */ 00302 void MCMCSetNChains(int n); 00303 00304 /* 00305 * Sets the lag of the Markov chains */ 00306 void MCMCSetNLag(int n) 00307 { fMCMCNLag = n; }; 00308 00309 /* 00310 * Sets the maximum number of iterations in the pre-run. */ 00311 void MCMCSetNIterationsMax(int n) 00312 { fMCMCNIterationsMax = n; }; 00313 00314 /* 00315 * Sets the number of iterations. */ 00316 void MCMCSetNIterationsRun(int n) 00317 { fMCMCNIterationsRun = n; }; 00318 00319 /* 00320 * Sets the minimum number of iterations in the pre-run */ 00321 void MCMCSetNIterationsPreRunMin(int n) 00322 { fMCMCNIterationsPreRunMin = n; }; 00323 00324 /* 00325 * Sets the number of iterations in the pre-run after which an 00326 * update on the statistics (convergence, efficiency, etc.) is done. 00327 * @param n The number of iterations.*/ 00328 void MCMCSetNIterationsUpdate(int n) 00329 { fMCMCNIterationsUpdate = n; }; 00330 00331 /* 00332 * Sets the maximum number of iterations in the pre-run after which an 00333 * update on the statistics (convergence, efficiency, etc.) is done. 00334 * If set to 0 no maximum is set. 00335 * @param n maximum number of iterations. */ 00336 void MCMCSetNIterationsUpdateMax(int n) 00337 { fMCMCNIterationsUpdateMax = n; }; 00338 00339 /* 00340 * Sets the minimum efficiency required for a chain. */ 00341 void MCMCSetMinimumEfficiency(double efficiency) 00342 { fMCMCEfficiencyMin = efficiency; }; 00343 00344 /* 00345 * Sets the maximum efficiency required for a chain. */ 00346 void MCMCSetMaximumEfficiency(double efficiency) 00347 { fMCMCEfficiencyMax = efficiency; }; 00348 00349 /* 00350 * Sets flag to write Markov chains to file. */ 00351 void MCMCSetWriteChainToFile(bool flag) 00352 { fMCMCFlagWriteChainToFile = flag; }; 00353 00354 /* 00355 * Sets flag to write pre run to file. */ 00356 void MCMCSetWritePreRunToFile(bool flag) 00357 { fMCMCFlagWritePreRunToFile = flag; }; 00358 00359 /* 00360 * Sets the initial positions for all chains. 00361 * @param x0s initial positions for all chains. */ 00362 void MCMCSetInitialPositions(std::vector<double> x0s); 00363 00364 /* 00365 * Sets the initial positions for all chains. 00366 * @param x0s initial positions for all chains. */ 00367 void MCMCSetInitialPositions(std::vector< std::vector<double> > x0s); 00368 00369 /* 00370 * Sets flag which defines initial position. */ 00371 void MCMCSetFlagInitialPosition(int flag) 00372 { fMCMCFlagInitialPosition = flag; }; 00373 00374 /* 00375 * Sets the flag which controls the sequence parameters during the 00376 * running of the MCMC. */ 00377 void MCMCSetFlagOrderParameters(bool flag) 00378 { fMCMCFlagOrderParameters = flag; }; 00379 00380 /* Sets the flag for all parameters to either fill histograms or not. */ 00381 void MCMCSetFlagFillHistograms(bool flag); 00382 00383 /* Sets the flag for a single parameter to either fill histograms or not. */ 00384 void MCMCSetFlagFillHistograms(int index, bool flag); 00385 00386 /* 00387 * Sets the R-value criterion for convergence of all chains. */ 00388 void MCMCSetRValueCriterion(double r) 00389 { fMCMCRValueCriterion = r; }; 00390 00391 /* 00392 * Sets the parameter R-value criterion for convergence of all chains */ 00393 void MCMCSetRValueParametersCriterion(double r) 00394 { fMCMCRValueParametersCriterion = r; }; 00395 00396 /* 00397 * Sets the tree containing the Markov chains. */ 00398 void MCMCSetMarkovChainTrees(std::vector <TTree *> trees); 00399 00400 /* 00401 * Initialize trees containing the Markov chains. */ 00402 void MCMCInitializeMarkovChainTrees(); 00403 00404 /* 00405 * Sets the histogram with 1D marginalized distributions for parameter. 00406 * @param i index of the parameter 00407 * @param h pointer to an existing histogram */ 00408 int SetMarginalized(int index, TH1D * h); 00409 00410 /* 00411 * Sets the histogram with 2D marginalized distributions for two parameters. 00412 * @param index1 index of the first parameter 00413 * @param index2 index of the second parameter 00414 * @param h pointer to an existing histogram */ 00415 int SetMarginalized(int index1, int index2, TH2D * h); 00416 00417 /* 00418 * Set the default values for the MCMC chain. */ 00419 void MCMCSetValuesDefault(); 00420 00421 /* 00422 * Set the values for a quick MCMC run. */ 00423 void MCMCSetValuesQuick(); 00424 00425 /* 00426 * Set the values for a detailed MCMC run. */ 00427 void MCMCSetValuesDetail(); 00428 00429 /** 00430 * Set the precision for the MCMC run. */ 00431 void MCMCSetPrecision(BCEngineMCMC::Precision precision); 00432 00433 /* @} */ 00434 /** \name Miscellaneous methods */ 00435 /* @{ */ 00436 00437 /* 00438 * Adds a parameter. 00439 * @param min minimum value of the parameter 00440 * @param max maximum value of the parameter 00441 * @return number of parameters after adding */ 00442 int MCMCAddParameter(double min, double max); 00443 00444 /* 00445 * Random walk trial function. The default trial function is a 00446 * Breit-Wigner. It can be overloaded by the user to set the trial 00447 * function. 00448 * @param ichain the chain index 00449 * @param x point with the dimension fMCMCNParameters */ 00450 virtual void MCMCTrialFunction(int ichain, std::vector <double> &x); 00451 00452 /* 00453 * Random walk trial function. The default trial function is a 00454 * Breit-Wigner. It can be overloaded by the user to set the trial 00455 * function. 00456 * @param ichain the chain index 00457 * @param ipar the parameter index 00458 * @return the unscaled proposal point */ 00459 virtual double MCMCTrialFunctionSingle(int ichain, int ipar); 00460 00461 /* 00462 * Returns a trial point for the Metropolis algorithm. 00463 * @param chain chain index 00464 * @param x proposal point 00465 * @return flag indicating whether the new point lies within the allowed range */ 00466 bool MCMCGetProposalPointMetropolis(int chain, std::vector <double> &x); 00467 00468 /* 00469 * Returns a trial point for the Metropolis algorithm. 00470 * @param chain chain index 00471 * @param x proposal point 00472 * @return flag indicating whether the new point lies within the allowed range */ 00473 bool MCMCGetProposalPointMetropolis(int chain, int parameter, std::vector <double> &x); 00474 00475 /* 00476 * Generates a new point using the Metropolis algorithm. 00477 * @param chain chain index */ 00478 bool MCMCGetNewPointMetropolis(int chain = 0); 00479 bool MCMCGetNewPointMetropolis(int chain, int parameter); 00480 00481 /* 00482 * Updates statistics: find new maximum */ 00483 void MCMCInChainCheckMaximum(); 00484 00485 /* 00486 * Updates statistics: */ 00487 void MCMCInChainUpdateStatistics(); 00488 00489 /* 00490 * Updates statistics: fill marginalized distributions */ 00491 void MCMCInChainFillHistograms(); 00492 00493 /* 00494 * Updates statistics: check convergence */ 00495 void MCMCInChainTestConvergenceAllChains(); 00496 00497 /* 00498 * Updates statistics: write chains to file */ 00499 void MCMCInChainWriteChains(); 00500 00501 /* 00502 * Needs to be overloaded in the derived class. 00503 * @return natural logarithm of the function to map with MCMC */ 00504 virtual double LogEval(std::vector <double> parameters); 00505 00506 /* 00507 * Runs Metropolis algorithm. */ 00508 int MCMCMetropolis(); 00509 00510 /* 00511 * Runs a pre run for the Metropolis algorithm. */ 00512 int MCMCMetropolisPreRun(); 00513 00514 /* 00515 * Resets the run statistics. */ 00516 void MCMCResetRunStatistics(); 00517 00518 /* 00519 * Initializes Markov chains. */ 00520 void MCMCInitializeMarkovChains(); 00521 00522 /* 00523 * Initializes the engine. 00524 * @return An error code */ 00525 int MCMCInitialize(); 00526 00527 /* 00528 * Reset the MCMC variables. 00529 * @return An error code */ 00530 int MCMCResetResults(); 00531 00532 /* 00533 * Interface allowing to execute arbitrary code for each iteration 00534 * of the MCMC. The frequency of calling this method is influenced 00535 * by the setup of the Lag and whether or not the MCMC is run with 00536 * ordered parameters. This method needs to be overloaded in the derived 00537 * class. */ 00538 virtual void MCMCIterationInterface() 00539 {}; 00540 00541 /* 00542 * Interface allowing to execute arbitrary code for each new point 00543 * of the MCMC. This method needs to be overloaded in the derived 00544 * class 00545 * @param point point that was generated and checked 00546 * @param ichain index of the chain 00547 * @param accepted flag whether or not the point was accepted for the chain 00548 */ 00549 virtual void MCMCCurrentPointInterface(std::vector <double> & point, int ichain, bool accepted) 00550 {}; 00551 00552 /* @} */ 00553 00554 private: 00555 00556 /* 00557 * Copies this BCEngineMCMC into another one. */ 00558 void Copy(BCEngineMCMC & enginemcmc) const; 00559 00560 /* 00561 * Defines a type of a pointer to a member function. */ 00562 typedef bool (BCEngineMCMC::*MCMCPointerToGetProposalPoint) (int chain, std::vector <double> xnew, std::vector <double> xold) const; 00563 00564 /* 00565 * Pointer to a member function */ 00566 MCMCPointerToGetProposalPoint fMCMCPointerToGetProposalPoint; 00567 00568 protected: 00569 00570 /* 00571 * Number of parameters */ 00572 int fMCMCNParameters; 00573 00574 /* 00575 * Parameter boundaries */ 00576 std::vector <double> fMCMCBoundaryMin; 00577 std::vector <double> fMCMCBoundaryMax; 00578 00579 /* 00580 * Parameter flags for marginalization */ 00581 std::vector <bool> fMCMCFlagsFillHistograms; 00582 00583 /* 00584 * Number of Markov chains ran in parallel */ 00585 int fMCMCNChains; 00586 00587 /* 00588 * The lag for the Markov Chain */ 00589 int fMCMCNLag; 00590 00591 /* 00592 * Number of total iterations of the Markov chains. The length of 00593 * the vector is equal to fMCMCNChains. */ 00594 std::vector<int> fMCMCNIterations; 00595 00596 /* 00597 * The current iteration number. If not called within the running 00598 * of the algorithm, return -1. */ 00599 int fMCMCCurrentIteration; 00600 00601 /* 00602 * The current chain index. If not called within the running of the 00603 * algorithm, return -1. */ 00604 int fMCMCCurrentChain; 00605 00606 /* 00607 * Number of iterations for updating scale factors */ 00608 int fMCMCNIterationsUpdate; 00609 00610 /* 00611 * Maximum number of iterations for updating scale factors */ 00612 int fMCMCNIterationsUpdateMax; 00613 00614 /* 00615 * Number of iterations needed for all chains to convergence 00616 * simulaneously */ 00617 int fMCMCNIterationsConvergenceGlobal; 00618 00619 /* 00620 * Flag for convergence */ 00621 bool fMCMCFlagConvergenceGlobal; 00622 00623 /* 00624 * Maximum number of iterations for a Markov chain prerun */ 00625 int fMCMCNIterationsMax; 00626 00627 /* 00628 * Number of iterations for a Markov chain run */ 00629 int fMCMCNIterationsRun; 00630 00631 /* 00632 * Minimum number of iterations for the pre-run */ 00633 int fMCMCNIterationsPreRunMin; 00634 00635 /* 00636 * Number of accepted trials for each chain. The length of the 00637 * vector is equal to fMCMCNChains * fMCMCNParameters. */ 00638 std::vector<int> fMCMCNTrialsTrue; 00639 00640 /* 00641 * Number of not accepted trials for each chain. The length of the 00642 * vector is equal to fMCMCNChains * fMCMCNParameters. */ 00643 std::vector<int> fMCMCNTrialsFalse; 00644 00645 /* 00646 * Flag to write Markov chains to file */ 00647 bool fMCMCFlagWriteChainToFile; 00648 00649 /* 00650 * Flag to write pre run to file */ 00651 bool fMCMCFlagWritePreRunToFile; 00652 00653 /* 00654 * Scales the width of the trial functions by a scale factor for 00655 * each parameter and chain */ 00656 std::vector <double> fMCMCTrialFunctionScaleFactor; 00657 00658 00659 /* 00660 * Start values of the scale factors for the trial functions. */ 00661 std::vector <double> fMCMCTrialFunctionScaleFactorStart; 00662 00663 /* 00664 * Defines if a prerun has been performed or not */ 00665 bool fMCMCFlagPreRun; 00666 00667 /* 00668 * Defines if MCMC has been performed or not */ 00669 bool fMCMCFlagRun; 00670 00671 /* 00672 * The intial position of each Markov chain. The length of the 00673 * vectors is equal to fMCMCNChains * fMCMCNParameters. First, the 00674 * values of the first Markov chain are saved, then those of the 00675 * second and so on */ 00676 std::vector <double> fMCMCInitialPosition; 00677 00678 /* 00679 * The minimum required efficiency for MCMC */ 00680 double fMCMCEfficiencyMin; 00681 00682 /* 00683 * The maximum allowed efficiency for MCMC */ 00684 double fMCMCEfficiencyMax; 00685 00686 /* 00687 * Variable which defines the initial position. 0 (default) center 00688 * of the allowed region, (1) random initial position (2) 00689 * pre-defined intial position. */ 00690 int fMCMCFlagInitialPosition; 00691 00692 /* 00693 * Flag which controls the sequence parameters during the running 00694 * of the MCMC. */ 00695 bool fMCMCFlagOrderParameters; 00696 00697 /* 00698 * Flag which controls fill histograms during main run. */ 00699 bool fMCMCFlagFillHistograms; 00700 00701 /* 00702 * The phase of the run. 00703 * 1: pre-run, 2: main run. 00704 */ 00705 int fMCMCPhase; 00706 00707 /* 00708 * The cycle of the pre-run 00709 */ 00710 int fMCMCCycle; 00711 00712 /* 00713 * The current points of each Markov chain. The length of the 00714 * vectors is equal to fMCMCNChains * fMCMCNParameters. First, the 00715 * values of the first Markov chain are saved, then those of the 00716 * second and so on. */ 00717 std::vector <double> fMCMCx; 00718 00719 /* 00720 * The maximum points of each Markov chain. The length of the vector 00721 * is fMCMCNChains * fMCMCNParameters. First, the values of the 00722 * first Markov chain are saved, then those of the second and so on. */ 00723 std::vector <double> fMCMCxMax; 00724 00725 /* 00726 * The mean of all parameters of each Markov chain. The length of 00727 * the vector is equal to fMCMCNChains * fMCMCNParameters. */ 00728 std::vector <double> fMCMCxMean; 00729 00730 /* 00731 * The variance of all parameters of each Markov chain. The length 00732 * of the vector is equal to fMCMCNChains * fMCMCNParameters. */ 00733 std::vector <double> fMCMCxVar; 00734 00735 /* 00736 * A temporary vector for a single Markov chain */ 00737 std::vector <double> fMCMCxLocal; 00738 00739 /* 00740 * The log of the probability of the current points of each Markov 00741 * chain. The length of the vectors is fMCMCNChains. */ 00742 std::vector<double> fMCMCprob; 00743 00744 /* 00745 * The maximum (log) probability of each Markov chain. The length of 00746 * the vector is fMCMCNChains. */ 00747 std::vector <double> fMCMCprobMax; 00748 00749 /* 00750 * The mean of all log prob values of each Markov chain. The 00751 * length of the vector is equal to fMCMCNChains. */ 00752 std::vector <double> fMCMCprobMean; 00753 00754 /* 00755 * The variance of all log prob values of each Markov chain. The 00756 * length of the vector is equal to fMCMCNChains. */ 00757 std::vector <double> fMCMCprobVar; 00758 00759 /* 00760 * The R-value criterion for convergence of log-likelihood*/ 00761 double fMCMCRValueCriterion; 00762 00763 /* 00764 * The R-value criterion for convergence of parameters */ 00765 double fMCMCRValueParametersCriterion; 00766 00767 /* 00768 * The R-value at which the chains did converge */ 00769 double fMCMCRValue; 00770 00771 /* The R-values for each parameter */ 00772 std::vector <double> fMCMCRValueParameters; 00773 00774 /* 00775 * Random number generator */ 00776 TRandom3 * fRandom; 00777 00778 /* 00779 * Number of bins per dimension for the marginalized distributions. */ 00780 std::vector<int> fMCMCH1NBins; 00781 00782 /* 00783 * An array of marginalized distributions */ 00784 std::vector <TH1D *> fMCMCH1Marginalized; 00785 std::vector <TH2D *> fMCMCH2Marginalized; 00786 00787 /* 00788 * The trees containing the Markov chains. The length of the vector 00789 * is fMCMCNChains. */ 00790 std::vector<TTree *> fMCMCTrees; 00791 }; 00792 00793 // --------------------------------------------------------- 00794 00795 #endif