00001 #ifndef __BCENGINEMCMC__H 00002 #define __BCENGINEMCMC__H 00003 00016 /* 00017 * Copyright (C) 2008, 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 class TPrincipal; 00033 00034 00035 // --------------------------------------------------------- 00036 00037 class BCEngineMCMC 00038 { 00039 00040 public: 00041 00043 /* @{ */ 00044 00047 BCEngineMCMC(); 00048 00052 BCEngineMCMC(int n); 00053 00056 BCEngineMCMC(const BCEngineMCMC & enginemcmc); 00057 00060 virtual ~BCEngineMCMC(); 00061 00062 /* @} */ 00064 /* @{ */ 00065 00068 BCEngineMCMC & operator = (const BCEngineMCMC & engineMCMC); 00069 00070 /* @} */ 00072 /* @{ */ 00073 00074 /* 00075 * @return number of parameters of the Markov chain */ 00076 int MCMCGetNParameters() 00077 { return fMCMCNParameters; }; 00078 00079 /* 00080 * @return number of Markov chains */ 00081 int MCMCGetNChains() 00082 { return fMCMCNChains; }; 00083 00084 /* 00085 * @return number of iterations */ 00086 std::vector <int> MCMCGetNIterations() 00087 { return fMCMCNIterations; }; 00088 00089 /* 00090 * @return pointer to the number of iterations */ 00091 std::vector <int> * MCMCGetP2NIterations() 00092 { return &fMCMCNIterations; }; 00093 00094 /* 00095 * @return number of iterations needed for each chain to 00096 * converge */ 00097 std::vector <int> MCMCGetNIterationsConvergenceLocal() 00098 { return fMCMCNIterationsConvergenceLocal; }; 00099 00100 /* 00101 * @return number of iterations needed for all chains to 00102 * converge simultaneously */ 00103 int MCMCGetNIterationsConvergenceGlobal() 00104 { return fMCMCNIterationsConvergenceGlobal; }; 00105 00106 /* 00107 * @return flag if converged or not */ 00108 bool MCMCGetFlagConvergenceGlobal() 00109 { return fMCMCFlagConvergenceGlobal; }; 00110 00111 /* 00112 * @return maximum number of iterations for a Markov chain */ 00113 int MCMCGetNIterationsMax() 00114 { return fMCMCNIterationsMax; }; 00115 00116 /* 00117 * @return number of iterations needed for burn-in. These 00118 * iterations are not included in fMCMCNIterations */ 00119 int MCMCGetNIterationsBurnIn() 00120 { return fMCMCNIterationsBurnIn; }; 00121 00122 /* 00123 * @return number of iterations needed for PCA. These 00124 * iterations are not included in fMCMCNIterations */ 00125 int MCMCGetNIterationsPCA() 00126 { return fMCMCNIterationsPCA; }; 00127 00128 /* 00129 * @returns number of accepted trials for each chain */ 00130 std::vector <int> MCMCGetNTrialsTrue() 00131 { return fMCMCNTrialsTrue; }; 00132 00133 /* 00134 * @returns number of not-accepted trials for each chain */ 00135 std::vector <int> MCMCGetNTrialsFalse() 00136 { return fMCMCNTrialsFalse; }; 00137 00138 /* 00139 * @return mean value of the probability for each chain up to 00140 * the current iteration */ 00141 std::vector <double> MCMCGetMean() 00142 { return fMCMCMean; }; 00143 00144 /* 00145 * @return mean value of the probability for each chain up to 00146 * the current iteration */ 00147 std::vector <double> MCMCGetVariance() 00148 { return fMCMCVariance; }; 00149 00150 /* 00151 * @return flag to automatically calculate the number of iterations 00152 * of a Markov chain */ 00153 bool MCMCGetFlagIterationsAuto() 00154 { return fMCMCFlagIterationsAuto; }; 00155 00156 /* 00157 * @return scale factor for the width of the trial function */ 00158 double MCMCGetTrialFunctionScale() 00159 { return fMCMCTrialFunctionScale; }; 00160 00161 /* 00162 * @return scale factor for all parameters and chains */ 00163 std::vector <double> MCMCGetTrialFunctionScaleFactor() 00164 { return fMCMCTrialFunctionScaleFactor; }; 00165 00166 /* 00167 * @return scale factor for all parameters and achain. 00168 * @param ichain chain index */ 00169 std::vector <double> MCMCGetTrialFunctionScaleFactor(int ichain); 00170 00171 /* 00172 * @return scale factor for a parameter and a chain. 00173 * @param ichain chain index 00174 * @param ipar parameter index */ 00175 double MCMCGetTrialFunctionScaleFactor(int ichain, int ipar); 00176 00177 /* 00178 * @return current point of each Markov chain */ 00179 std::vector <double> MCMCGetx() 00180 { return fMCMCx; }; 00181 00182 /* 00183 * @return pointer of each Markov chain */ 00184 std::vector <double> * MCMCGetP2x() 00185 { return &fMCMCx; }; 00186 00187 /* 00188 * @param ichain index of the Markov chain 00189 * @return current point of the Markov chain */ 00190 std::vector <double> MCMCGetx(int ichain); 00191 00192 /* 00193 * @param ichain chain index 00194 * @param ipar parameter index 00195 * @return parameter of the Markov chain */ 00196 double MCMCGetx(int ichain, int ipar); 00197 00198 /* 00199 * @return log of the probability of the current points of each Markov chain */ 00200 std::vector <double> MCMCGetLogProbx() 00201 { return fMCMCLogProbx; }; 00202 00203 /* 00204 * @return log of the probability of the current points of the Markov chain. 00205 * @param ichain chain index */ 00206 double MCMCGetLogProbx(int ichain); 00207 00208 /* 00209 * @return pointer to the log of the probability of the current points of each Markov chain */ 00210 std::vector <double> * MCMCGetP2LogProbx() 00211 { return &fMCMCLogProbx; }; 00212 00213 /* 00214 * @return maximum points of each Markov chain */ 00215 std::vector <double> MCMCGetMaximumPoints() 00216 { return fMCMCMaximumPoints; }; 00217 00218 /* 00219 * @return maximum point of Markov chain 00220 * @param i The index of the Markov chain */ 00221 std::vector <double> MCMCGetMaximumPoint(int i); 00222 00223 /* 00224 * @return maximum (log) probability of each Markov chain */ 00225 std::vector <double> MCMCGetMaximumLogProb() 00226 { return fMCMCMaximumLogProb; }; 00227 00228 /* 00229 * @return control plots */ 00230 // TH1D * MCMCGetH1RValue() 00231 // { return fMCMCH1RValue; }; 00232 00233 // TH1D * MCMCGetH1Efficiency() 00234 // { return fMCMCH1Efficiency; }; 00235 00236 /* 00237 * @return flag which defined initial position */ 00238 int MCMCGetFlagInitialPosition() 00239 { return fMCMCFlagInitialPosition; }; 00240 00241 /* 00242 * @return R-value criterion */ 00243 double MCMCGetRValueCriterion() 00244 { return fMCMCRValueCriterion; }; 00245 00246 /* 00247 * @return R-value criterion for parameters */ 00248 double MCMCGetRValueParametersCriterion() 00249 { return fMCMCRValueParametersCriterion; }; 00250 00251 /* 00252 * @return R-value */ 00253 double MCMCGetRValue() 00254 { return fMCMCRValue; }; 00255 00256 /* 00257 * @return R-value for a parameter 00258 * @param i parameter index */ 00259 double MCMCGetRValueParameters(int i) 00260 { return fMCMCRValueParameters.at(i); }; 00261 00262 /* 00263 * @return the relative precision for the estimate of the mode */ 00264 // double MCMCGetPrecisionMode() 00265 // { return fMCMCRelativePrecisionMode; }; 00266 00267 /* 00268 * @return the flag for the use of PCA */ 00269 bool MCMCGetFlagPCA() 00270 { return fMCMCFlagPCA; }; 00271 00272 /* 00273 * Rtrieve the tree containing the Markov chain. 00274 * @param i index of the Markov chain 00275 * @return pointer to the tree */ 00276 TTree * MCMCGetMarkovChainTree(int i) 00277 { return fMCMCTrees.at(i); }; 00278 00279 /* 00280 * Retrieve a histogram of the 1D marginalized distribution of a single parameter. 00281 * @param i index of the parameter 00282 * @return pointer to the histogram */ 00283 TH1D * MCMCGetH1Marginalized(int i) 00284 { return fMCMCH1Marginalized[i]; }; 00285 00286 /* 00287 * Retrieve a histogram of the 2D marginalized distribution for two parameters. 00288 * @param i index of the first parameter 00289 * @param j index of the second parameter 00290 * @return pointer to the histogram */ 00291 TH2D * MCMCGetH2Marginalized(int i, int j); 00292 00293 /* @} */ 00295 /* @{ */ 00296 00297 /* 00298 * Sets the scale factor for the width of the trial function. */ 00299 void MCMCSetTrialFunctionScale(double scale) 00300 { fMCMCTrialFunctionScale = scale; }; 00301 00302 void MCMCSetTrialFunctionScaleFactor(std::vector <double> scale) 00303 { fMCMCTrialFunctionScaleFactorStart = scale; }; 00304 00305 /* 00306 * Sets the number of parameters of the Markov chain. */ 00307 // void MCMCSetNParameters(int n); 00308 00309 /* 00310 * Sets the number of Markov chains which are run in parallel. */ 00311 void MCMCSetNChains(int n); 00312 00313 /* 00314 * Sets the maximum number of iterations. */ 00315 void MCMCSetNIterationsMax(int n) 00316 { fMCMCNIterationsMax = n; }; 00317 00318 /* 00319 * Sets the number of iterations. */ 00320 void MCMCSetNIterationsRun(int n) 00321 { fMCMCNIterationsRun = n; }; 00322 00323 /* 00324 * Sets the number of iterations needed for burn-in. */ 00325 void MCMCSetNIterationsBurnIn(int n) 00326 { fMCMCNIterationsBurnIn = n; }; 00327 00328 /* 00329 * Sets the number of iterations needed for PCA. */ 00330 void MCMCSetNIterationsPCA(int n) 00331 { fMCMCNIterationsPCA = n; }; 00332 00333 void MCMCSetNIterationsUpdate(int n) 00334 { fMCMCNIterationsUpdate = n; }; 00335 00336 /* 00337 * Sets flag to automatically calculate the number of iterations of 00338 * a Markov chain. */ 00339 void MCMCSetIterationsAuto(bool flag) 00340 { fMCMCFlagIterationsAuto = flag; }; 00341 00342 /* 00343 * Sets the minimum efficiency required for a chain. */ 00344 void MCMCSetMinimumEfficiency(double efficiency) 00345 { fMCMCEfficiencyMin = efficiency; }; 00346 00347 /* 00348 * Sets the maximum efficiency required for a chain. */ 00349 void MCMCSetMaximumEfficiency(double efficiency) 00350 { fMCMCEfficiencyMax = efficiency; }; 00351 00352 /* 00353 * Sets flag to write Markov chains to file. */ 00354 void MCMCSetWriteChainToFile(bool flag) 00355 { fMCMCFlagWriteChainToFile = flag; }; 00356 00357 /* 00358 * Sets the initial position for a chain. 00359 * @param chain chain index. 00360 * @param x0 intial position 00361 * @see MCMCSetIntitialPositions. */ 00362 void MCMCSetInitialPosition(std::vector<double> x0); 00363 void MCMCSetInitialPosition(int chain, std::vector<double> x0); 00364 00365 /* 00366 * Sets the initial positions for all chains. 00367 * @param x0s initial positions for all chains */ 00368 void MCMCSetInitialPositions(std::vector<double> x0s); 00369 00370 /* 00371 * Sets flag which defined initial position. 00372 */ 00373 void MCMCSetFlagInitialPosition(int flag) 00374 { fMCMCFlagInitialPosition = flag; }; 00375 00376 /* 00377 * Sets the flag which controls the sequence parameters during the running 00378 * of the MCMC. */ 00379 void MCMCSetFlagOrderParameters(bool flag) 00380 { fMCMCFlagOrderParameters = flag; }; 00381 00382 /* 00383 * Sets the R-value criterion for convergence of all chains. */ 00384 void MCMCSetRValueCriterion(double r) 00385 { fMCMCRValueCriterion = r; }; 00386 00387 /* 00388 * Sets the parameter R-value criterion for convergence of all chains */ 00389 void MCMCSetRValueParametersCriterion(double r) 00390 { fMCMCRValueParametersCriterion = r; }; 00391 00392 /* 00393 * Sets the relative precision for the estimate of the mode. */ 00394 // void MCMCSetPrecisionMode(double precision) 00395 // { fMCMCRelativePrecisionMode = precision; }; 00396 00397 /* 00398 * Sets the flag to either perform a pre-run with PCA or not. */ 00399 void MCMCSetFlagPCA(bool flag) 00400 { fMCMCFlagPCA = flag; }; 00401 00402 /* 00403 * Sets the tree containing the Markov chains. */ 00404 void MCMCSetMarkovChainTrees(std::vector <TTree *> trees); 00405 00406 /* 00407 * Set a flag to control if during the PCA the least eigenvectors 00408 * should be ignored or not. */ 00409 void MCMCSetFlagPCATruncate(bool flag) 00410 { fMCMCFlagPCATruncate = flag; }; 00411 00412 /* 00413 * Sets the minimum ratio of an eigenvalue to the largest eigenvalue 00414 * below which it is ignored if fMCMCFlagPCATruncate is true. */ 00415 void MCMCSetPCAMinimumRatio(double ratio) 00416 { fMCMCPCAMinimumRatio = ratio; }; 00417 00418 /* @} */ 00420 /* @{ */ 00421 00422 /* 00423 * Adds a parameter. 00424 * @param min minimum value of the parameter 00425 * @param max maximum value of the parameter 00426 * @return number of parameters after adding */ 00427 int MCMCAddParameter(double min, double max); 00428 00429 /* 00430 * Random walk trial function. The function is symmetric and 00431 * used for the Metropolis algorithm. 00432 * @param x point with the dimension fMCMCNParameters */ 00433 void MCMCTrialFunction(std::vector <double> &x); 00434 void MCMCTrialFunctionSingle(int ichain, int iparameter, std::vector <double> &x); 00435 00436 /* 00437 * Independent chain trial function. The function does not 00438 * have to be symmetric and is used for the 00439 * Metropolis-Hastings algorithm. 00440 * @param x point with the dimension fMCMCNParameters 00441 * @return transition probability */ 00442 double MCMCTrialFunctionIndependent(std::vector <double> &xnew, std::vector <double> &xold, bool newpoint); 00443 00444 /* 00445 * Trial function. 00446 * @param x point with the dimension fMCMCNParameters */ 00447 void MCMCTrialFunctionAuto(std::vector <double> &x); 00448 00449 /* 00450 * Trial function for the MCMC relative to the old point. No PCA. 00451 * @param pxold pointer to the old point. The length of the vector equals to fMCMCNParameters. 00452 * @param pxnew pointer to the new point. The length of the vector equals to fMCMCNParameters. 00453 * @param flag_compute flag which indicates whether to compute a new point (true) or to just pass the value of the function (flase) 00454 * @return value of the trial function */ 00455 // double MCMCTrialFunctionRelativeNoPCA(std::vector <double> * xold, std::vector<double> * xnew, bool flag_compute); 00456 00457 /* 00458 * not documented !!! */ 00459 // void MCMCGetProposalPoint(int chain, std::vector <double> xnew, std::vector <double> xold); 00460 00461 /* 00462 * Returns a trial point for the Metropolis algorithm. 00463 * @param chain chain index 00464 * @param x proposal point 00465 * @param pca bool whether to use PCA or not 00466 * @return flag indicating whether the new point lies within the allowed range */ 00467 bool MCMCGetProposalPointMetropolis(int chain, std::vector <double> &x, bool pca); 00468 00469 /* 00470 * Returns a trial point for the Metropolis algorithm. 00471 * @param chain chain index 00472 * @param x proposal point 00473 * @param pca bool whether to use PCA or not 00474 * @return flag indicating whether the new point lies within the allowed range */ 00475 bool MCMCGetProposalPointMetropolis(int chain, int parameter, std::vector <double> &x, bool pca); 00476 00477 /* 00478 * Returns a trial point for the Metropolis algorithm. 00479 * @param chain chain index 00480 * @param x proposal point 00481 * @param pca bool whether to use PCA or not 00482 * @return flag indicating whether the new point lies within the allowed range */ 00483 bool MCMCGetProposalPointMetropolisHastings(int chain, std::vector <double> &xnew, std::vector <double> &xold); 00484 00485 /* 00486 * This method samples uniformly over the allowed parameter space. 00487 * @return new point for the PCA run */ 00488 void MCMCGetNewPointPCA(); 00489 00490 /* 00491 * Generates a new point using the Metropolis algorithm. 00492 * @param chain chain index 00493 * @param pca bool whether to use PCA or not */ 00494 bool MCMCGetNewPointMetropolis(int chain = 0, bool pca = false); 00495 bool MCMCGetNewPointMetropolis(int chain, int parameter, bool pca = false); 00496 00497 /* 00498 * Generates a new point using the Metropolis algorithm. 00499 * @param chain chain index */ 00500 bool MCMCGetNewPointMetropolisHastings(int chain = 0); 00501 00502 /* 00503 * Updates statistics, plots, etc. */ 00504 void MCMCUpdateStatistics(); 00505 void MCMCUpdateStatisticsModeConvergence(); 00506 void MCMCUpdateStatisticsCheckMaximum(); 00507 void MCMCUpdateStatisticsFillHistograms(); 00508 void MCMCUpdateStatisticsTestConvergenceAllChains(); 00509 void MCMCUpdateStatisticsWriteChains(); 00510 00511 /* 00512 * Needs to be overloaded in the derived class. 00513 * @return natural logarithm of the function to map with MCMC */ 00514 virtual double LogEval(std::vector <double> parameters); 00515 00516 /* 00517 * Perform a run for the PCA */ 00518 // void MCMCPCARun(); 00519 00520 /* 00521 * Runs Metropolis algorithm. */ 00522 int MCMCMetropolis(); 00523 00524 /* 00525 * Runs a pre run for the Metropolis algorithm. */ 00526 int MCMCMetropolisPreRun(); 00527 00528 /* 00529 * Runs Metropolis-Hastings algorithm. */ 00530 int MCMCMetropolisHastings(); 00531 00532 /* 00533 * Performs an initial run. */ 00534 // void MCMCInitialRun(); 00535 00536 /* 00537 * Resets the run statistics. */ 00538 void MCMCResetRunStatistics(); 00539 00540 /* 00541 * Initializes Markov chains. */ 00542 void MCMCInitializeMarkovChains(); 00543 00544 /* 00545 * Initializes the engine. */ 00546 int MCMCInitialize(); 00547 00548 /* 00549 * Interface allowing to execute arbitrary code for each iteration of the MCMC. 00550 * This method needs to be overloaded in the derived class. */ 00551 virtual void MCMCIterationInterface() 00552 {}; 00553 00554 /* 00555 * Sets the histogram with 1D marginalized distributions for parameter. 00556 * @param i index of the parameter 00557 * @param h pointer to an existing histogram */ 00558 int SetMarginalized(int index, TH1D * h); 00559 00560 /* 00561 * Sets the histogram with 2D marginalized distributions for two parameters. 00562 * @param index1 index of the first parameter 00563 * @param index2 index of the second parameter 00564 * @param h pointer to an existing histogram */ 00565 int SetMarginalized(int index1, int index2, TH2D * h); 00566 00569 void MCMCSetValuesDefault(); 00570 00573 void MCMCSetValuesQuick(); 00574 00577 void MCMCSetValuesDetail(); 00578 00579 /* @} */ 00580 00581 private: 00582 00583 /* 00584 * Copies this BCEngineMCMC into another one. */ 00585 void Copy(BCEngineMCMC & enginemcmc) const; 00586 00587 /* 00588 * Defines a type of a pointer to a member function. */ 00589 typedef bool (BCEngineMCMC::*MCMCPointerToGetProposalPoint) (int chain, std::vector <double> xnew, std::vector <double> xold) const; 00590 00591 /* 00592 * Pointer to a member function */ 00593 MCMCPointerToGetProposalPoint fMCMCPointerToGetProposalPoint; 00594 00595 protected: 00596 00597 /* 00598 * Number of parameters */ 00599 int fMCMCNParameters; 00600 00601 /* 00602 * Parameter boundaries */ 00603 std::vector <double> fMCMCBoundaryMin; 00604 std::vector <double> fMCMCBoundaryMax; 00605 00606 /* 00607 * Number of Markov chains ran in parallel */ 00608 int fMCMCNChains; 00609 00610 /* 00611 * Number of total iterations of the Markov chains. The length of 00612 * the vector is equal to fMCMCNChains. */ 00613 std::vector<int> fMCMCNIterations; 00614 00615 /* 00616 * Number of iterations for updating scale factors */ 00617 int fMCMCNIterationsUpdate; 00618 00619 /* 00620 * Number of iterations needed for each chain to convergence. The 00621 * size of the vector is equal to fMCMCNChains. */ 00622 std::vector<int> fMCMCNIterationsConvergenceLocal; 00623 00624 /* 00625 * Number of iterations needed for all chains to convergence simulaneously */ 00626 int fMCMCNIterationsConvergenceGlobal; 00627 00628 /* 00629 * Flag for convergence */ 00630 bool fMCMCFlagConvergenceGlobal; 00631 00632 /* 00633 * Maximum number of iterations for a Markov chain prerun */ 00634 int fMCMCNIterationsMax; 00635 00636 /* 00637 * Number of iterations for a Markov chain run */ 00638 int fMCMCNIterationsRun; 00639 00640 /* 00641 * Minimum number of iterations for the pre-run */ 00642 int fMCMCNIterationsPreRunMin; 00643 00644 /* 00645 * Number of iterations for burn-in. These iterations are not 00646 * included in fMCMCNIterations. */ 00647 int fMCMCNIterationsBurnIn; 00648 00649 /* 00650 * Number of iterations for PCA. These iterations are not included 00651 * in FMCMCNIterations. */ 00652 int fMCMCNIterationsPCA; 00653 00654 /* 00655 * Mean values of the data in the PCA coordinate system */ 00656 std::vector <double> fMCMCPCAMean; 00657 00658 /* 00659 * Variance of the data in the PCA coordinate system */ 00660 std::vector <double> fMCMCPCAVariance; 00661 00662 /* 00663 * Flag to control if during the PCA the least eigenvectors should 00664 * be ignored or not */ 00665 bool fMCMCFlagPCATruncate; 00666 00667 /* 00668 * Minimum ratio of an eigenvalue to the largest eigenvalue below 00669 * which it is ignored if fMCMCFlagPCATruncate is true */ 00670 double fMCMCPCAMinimumRatio; 00671 00672 /* 00673 * If the least eigenvectors are ignored this is the number of 00674 * dimensions remaining */ 00675 int fMCMCNDimensionsPCA; 00676 00677 /* 00678 * Number of accepted trials and not accepted trials for each 00679 * chain. The length of the vectors is equal to fMCMCNChains * 00680 * fMCMCNParameters. For each chain these numbers add up to 00681 * fMCMCNIterations. */ 00682 std::vector<int> fMCMCNTrialsTrue; 00683 std::vector<int> fMCMCNTrialsFalse; 00684 00685 /* 00686 * The mean and variance of all values of each Markov chain. The 00687 * length of the vectors is equal to fMCMCNChains. */ 00688 std::vector <double> fMCMCMean; 00689 std::vector <double> fMCMCVariance; 00690 00691 /* 00692 * The sum and sum squared of all values of each Markov chain. These 00693 * are used to calculate the mean and variance of each chain. The 00694 * length of the vectors is equal to fMCMCNChains. */ 00695 std::vector <double> fMCMCSum; 00696 std::vector <double> fMCMCSum2; 00697 00698 /* 00699 * The mean and variance of all parameters of each Markov chain. The 00700 * length of the vectors is equal to fMCMCNChains * fMCMCNParameters. */ 00701 std::vector <double> fMCMCMeanx; 00702 std::vector <double> fMCMCVariancex; 00703 00704 /* 00705 * Flag to automatically calculate the number of iterations of a 00706 * Markov chain */ 00707 bool fMCMCFlagIterationsAuto; 00708 00709 /* 00710 * Flag to write Markov chains to file */ 00711 bool fMCMCFlagWriteChainToFile; 00712 00713 /* 00714 * Scales the width of the trial functions by a global factor */ 00715 double fMCMCTrialFunctionScale; 00716 00717 /* 00718 * Scales the width of the trial functions by a scale factor 00719 * for each parameter and chain */ 00720 std::vector <double> fMCMCTrialFunctionScaleFactor; 00721 std::vector <double> fMCMCTrialFunctionScaleFactorStart; 00722 00723 /* 00724 * Defines if a prerun has been performed or not */ 00725 bool fMCMCFlagPreRun; 00726 00727 /* 00728 * The intial position of each Markov chain. The length of the 00729 * vectors is equal to fMCMCNChains * fMCMCNParameters. First, the 00730 * values of the first Markov chain are saved, then those of the 00731 * second and so on */ 00732 std::vector <double> fMCMCInitialPosition; 00733 00734 /* 00735 * Minimum efficiency for MCMC */ 00736 double fMCMCEfficiencyMin; 00737 00738 /* 00739 * Maximum efficiency for MCMC */ 00740 double fMCMCEfficiencyMax; 00741 00742 /* 00743 * Variable which defines the initial position. 0 (default) center 00744 * of the allowed region, (1) random initial position (2) 00745 * pre-defined intial position. */ 00746 int fMCMCFlagInitialPosition; 00747 00748 /* 00749 * Flag which controls the sequence parameters during the running 00750 * of the MCMC. */ 00751 bool fMCMCFlagOrderParameters; 00752 00753 /* 00754 * The current points of each Markov chain. The length of the 00755 * vectors is equal to fMCMCNChains * fMCMCNParameters. First, the 00756 * values of the first Markov chain are saved, then those of the 00757 * second and so on. */ 00758 std::vector <double> fMCMCx; 00759 00760 /* 00761 * A temporary vector for a single Markov chain */ 00762 std::vector <double> fMCMCxLocal; 00763 00764 /* 00765 * The log of the probability of the current points of each Markov 00766 * chain. The length of the vectors is fMCMCNChains. */ 00767 std::vector<double> fMCMCLogProbx; 00768 00769 /* 00770 * The maximum points of each Markov chain. The length of the vector 00771 * is fMCMCNChains * fMCMCNParameters. First, the values of the 00772 * first Markov chain are saved, then those of the second and so on. */ 00773 std::vector <double> fMCMCMaximumPoints; 00774 00775 /* 00776 * The maximum (log) probability of each Markov chain. The length of 00777 * the vector is fMCMCNChains. */ 00778 std::vector <double> fMCMCMaximumLogProb; 00779 00780 /* 00781 * The R-value criterion for convergence of log-likelihood*/ 00782 double fMCMCRValueCriterion; 00783 00784 /* 00785 * The R-value criterion for convergence of parameters */ 00786 double fMCMCRValueParametersCriterion; 00787 00788 /* 00789 * The R-value at which the chains did converge */ 00790 double fMCMCRValue; 00791 00792 std::vector <double> fMCMCRValueParameters; 00793 00794 /* 00795 * The relative precision for the convergence of the modes of 00796 * several chains */ 00797 // double fMCMCRelativePrecisionMode; 00798 00799 // std::vector <double> fMCMCRelativePrecisionModeValues; 00800 std::vector <double> fMCMCNumericalPrecisionModeValues; 00801 00802 /* 00803 * Random number generator */ 00804 TRandom3 * fMCMCRandom; 00805 00806 /* 00807 * PCA */ 00808 TPrincipal * fMCMCPCA; 00809 00810 /* 00811 * Flag to perform PCA or not */ 00812 bool fMCMCFlagPCA; 00813 00814 /* 00815 * Number of bins per dimension for the marginalized distributions. */ 00816 std::vector<int> fMCMCH1NBins; 00817 00818 /* 00819 * An array of marginalized distributions */ 00820 std::vector <TH1D *> fMCMCH1Marginalized; 00821 std::vector <TH2D *> fMCMCH2Marginalized; 00822 00823 /* 00824 * Control plots */ 00825 // TH1D * fMCMCH1RValue; // R-value 00826 // TH1D * fMCMCH1Efficiency; // Efficiency of the Markov chain 00827 00828 /* 00829 * The trees containing the Markov chains. The length of the vector 00830 * is fMCMCNChains. */ 00831 std::vector<TTree *> fMCMCTrees; 00832 }; 00833 00834 // --------------------------------------------------------- 00835 00836 #endif