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 minimum number of iterations in the pre-run */ 00330 void MCMCSetNIterationsPreRunMin(int n) 00331 { fMCMCNIterationsPreRunMin = n; }; 00332 00333 /* 00334 * Sets the number of iterations needed for PCA. */ 00335 void MCMCSetNIterationsPCA(int n) 00336 { fMCMCNIterationsPCA = n; }; 00337 00338 void MCMCSetNIterationsUpdate(int n) 00339 { fMCMCNIterationsUpdate = n; }; 00340 00341 /* 00342 * Sets flag to automatically calculate the number of iterations of 00343 * a Markov chain. */ 00344 void MCMCSetIterationsAuto(bool flag) 00345 { fMCMCFlagIterationsAuto = flag; }; 00346 00347 /* 00348 * Sets the minimum efficiency required for a chain. */ 00349 void MCMCSetMinimumEfficiency(double efficiency) 00350 { fMCMCEfficiencyMin = efficiency; }; 00351 00352 /* 00353 * Sets the maximum efficiency required for a chain. */ 00354 void MCMCSetMaximumEfficiency(double efficiency) 00355 { fMCMCEfficiencyMax = efficiency; }; 00356 00357 /* 00358 * Sets flag to write Markov chains to file. */ 00359 void MCMCSetWriteChainToFile(bool flag) 00360 { fMCMCFlagWriteChainToFile = flag; }; 00361 00362 /* 00363 * Sets the initial positions for all chains. 00364 * @param x0s initial positions for all chains. */ 00365 void MCMCSetInitialPositions(std::vector<double> x0s); 00366 void MCMCSetInitialPositions(std::vector< std::vector<double> > x0s); 00367 00368 /* 00369 * Sets flag which defined initial position. 00370 */ 00371 void MCMCSetFlagInitialPosition(int flag) 00372 { fMCMCFlagInitialPosition = flag; }; 00373 00374 /* 00375 * Sets the flag which controls the sequence parameters during the running 00376 * of the MCMC. */ 00377 void MCMCSetFlagOrderParameters(bool flag) 00378 { fMCMCFlagOrderParameters = flag; }; 00379 00380 /* 00381 * Sets the R-value criterion for convergence of all chains. */ 00382 void MCMCSetRValueCriterion(double r) 00383 { fMCMCRValueCriterion = r; }; 00384 00385 /* 00386 * Sets the parameter R-value criterion for convergence of all chains */ 00387 void MCMCSetRValueParametersCriterion(double r) 00388 { fMCMCRValueParametersCriterion = r; }; 00389 00390 /* 00391 * Sets the relative precision for the estimate of the mode. */ 00392 // void MCMCSetPrecisionMode(double precision) 00393 // { fMCMCRelativePrecisionMode = precision; }; 00394 00395 /* 00396 * Sets the flag to either perform a pre-run with PCA or not. */ 00397 void MCMCSetFlagPCA(bool flag) 00398 { fMCMCFlagPCA = flag; }; 00399 00400 /* 00401 * Sets the tree containing the Markov chains. */ 00402 void MCMCSetMarkovChainTrees(std::vector <TTree *> trees); 00403 00404 /* 00405 * Set a flag to control if during the PCA the least eigenvectors 00406 * should be ignored or not. */ 00407 void MCMCSetFlagPCATruncate(bool flag) 00408 { fMCMCFlagPCATruncate = flag; }; 00409 00410 /* 00411 * Sets the minimum ratio of an eigenvalue to the largest eigenvalue 00412 * below which it is ignored if fMCMCFlagPCATruncate is true. */ 00413 void MCMCSetPCAMinimumRatio(double ratio) 00414 { fMCMCPCAMinimumRatio = ratio; }; 00415 00416 /* @} */ 00418 /* @{ */ 00419 00420 /* 00421 * Adds a parameter. 00422 * @param min minimum value of the parameter 00423 * @param max maximum value of the parameter 00424 * @return number of parameters after adding */ 00425 int MCMCAddParameter(double min, double max); 00426 00427 /* 00428 * Random walk trial function. The function is symmetric and 00429 * used for the Metropolis algorithm. 00430 * @param x point with the dimension fMCMCNParameters */ 00431 void MCMCTrialFunction(std::vector <double> &x); 00432 void MCMCTrialFunctionSingle(int ichain, int iparameter, std::vector <double> &x); 00433 00434 /* 00435 * Independent chain trial function. The function does not 00436 * have to be symmetric and is used for the 00437 * Metropolis-Hastings algorithm. 00438 * @param x point with the dimension fMCMCNParameters 00439 * @return transition probability */ 00440 double MCMCTrialFunctionIndependent(std::vector <double> &xnew, std::vector <double> &xold, bool newpoint); 00441 00442 /* 00443 * Trial function. 00444 * @param x point with the dimension fMCMCNParameters */ 00445 void MCMCTrialFunctionAuto(std::vector <double> &x); 00446 00447 /* 00448 * Trial function for the MCMC relative to the old point. No PCA. 00449 * @param pxold pointer to the old point. The length of the vector equals to fMCMCNParameters. 00450 * @param pxnew pointer to the new point. The length of the vector equals to fMCMCNParameters. 00451 * @param flag_compute flag which indicates whether to compute a new point (true) or to just pass the value of the function (flase) 00452 * @return value of the trial function */ 00453 // double MCMCTrialFunctionRelativeNoPCA(std::vector <double> * xold, std::vector<double> * xnew, bool flag_compute); 00454 00455 /* 00456 * not documented !!! */ 00457 // void MCMCGetProposalPoint(int chain, std::vector <double> xnew, std::vector <double> xold); 00458 00459 /* 00460 * Returns a trial point for the Metropolis algorithm. 00461 * @param chain chain index 00462 * @param x proposal point 00463 * @param pca bool whether to use PCA or not 00464 * @return flag indicating whether the new point lies within the allowed range */ 00465 bool MCMCGetProposalPointMetropolis(int chain, std::vector <double> &x, bool pca); 00466 00467 /* 00468 * Returns a trial point for the Metropolis algorithm. 00469 * @param chain chain index 00470 * @param x proposal point 00471 * @param pca bool whether to use PCA or not 00472 * @return flag indicating whether the new point lies within the allowed range */ 00473 bool MCMCGetProposalPointMetropolis(int chain, int parameter, std::vector <double> &x, bool pca); 00474 00475 /* 00476 * Returns a trial point for the Metropolis algorithm. 00477 * @param chain chain index 00478 * @param x proposal point 00479 * @param pca bool whether to use PCA or not 00480 * @return flag indicating whether the new point lies within the allowed range */ 00481 bool MCMCGetProposalPointMetropolisHastings(int chain, std::vector <double> &xnew, std::vector <double> &xold); 00482 00483 /* 00484 * This method samples uniformly over the allowed parameter space. 00485 * @return new point for the PCA run */ 00486 void MCMCGetNewPointPCA(); 00487 00488 /* 00489 * Generates a new point using the Metropolis algorithm. 00490 * @param chain chain index 00491 * @param pca bool whether to use PCA or not */ 00492 bool MCMCGetNewPointMetropolis(int chain = 0, bool pca = false); 00493 bool MCMCGetNewPointMetropolis(int chain, int parameter, bool pca = false); 00494 00495 /* 00496 * Generates a new point using the Metropolis algorithm. 00497 * @param chain chain index */ 00498 bool MCMCGetNewPointMetropolisHastings(int chain = 0); 00499 00500 /* 00501 * Updates statistics, plots, etc. */ 00502 void MCMCUpdateStatistics(); 00503 void MCMCUpdateStatisticsModeConvergence(); 00504 void MCMCUpdateStatisticsCheckMaximum(); 00505 void MCMCUpdateStatisticsFillHistograms(); 00506 void MCMCUpdateStatisticsTestConvergenceAllChains(); 00507 void MCMCUpdateStatisticsWriteChains(); 00508 00509 /* 00510 * Needs to be overloaded in the derived class. 00511 * @return natural logarithm of the function to map with MCMC */ 00512 virtual double LogEval(std::vector <double> parameters); 00513 00514 /* 00515 * Perform a run for the PCA */ 00516 // void MCMCPCARun(); 00517 00518 /* 00519 * Runs Metropolis algorithm. */ 00520 int MCMCMetropolis(); 00521 00522 /* 00523 * Runs a pre run for the Metropolis algorithm. */ 00524 int MCMCMetropolisPreRun(); 00525 00526 /* 00527 * Runs Metropolis-Hastings algorithm. */ 00528 int MCMCMetropolisHastings(); 00529 00530 /* 00531 * Performs an initial run. */ 00532 // void MCMCInitialRun(); 00533 00534 /* 00535 * Resets the run statistics. */ 00536 void MCMCResetRunStatistics(); 00537 00538 /* 00539 * Initializes Markov chains. */ 00540 void MCMCInitializeMarkovChains(); 00541 00542 /* 00543 * Initializes the engine. */ 00544 int MCMCInitialize(); 00545 00546 /* 00547 * Interface allowing to execute arbitrary code for each iteration of the MCMC. 00548 * This method needs to be overloaded in the derived class. */ 00549 virtual void MCMCIterationInterface() 00550 {}; 00551 00552 /* 00553 * Sets the histogram with 1D marginalized distributions for parameter. 00554 * @param i index of the parameter 00555 * @param h pointer to an existing histogram */ 00556 int SetMarginalized(int index, TH1D * h); 00557 00558 /* 00559 * Sets the histogram with 2D marginalized distributions for two parameters. 00560 * @param index1 index of the first parameter 00561 * @param index2 index of the second parameter 00562 * @param h pointer to an existing histogram */ 00563 int SetMarginalized(int index1, int index2, TH2D * h); 00564 00567 void MCMCSetValuesDefault(); 00568 00571 void MCMCSetValuesQuick(); 00572 00575 void MCMCSetValuesDetail(); 00576 00577 /* @} */ 00578 00579 private: 00580 00581 /* 00582 * Copies this BCEngineMCMC into another one. */ 00583 void Copy(BCEngineMCMC & enginemcmc) const; 00584 00585 /* 00586 * Defines a type of a pointer to a member function. */ 00587 typedef bool (BCEngineMCMC::*MCMCPointerToGetProposalPoint) (int chain, std::vector <double> xnew, std::vector <double> xold) const; 00588 00589 /* 00590 * Pointer to a member function */ 00591 MCMCPointerToGetProposalPoint fMCMCPointerToGetProposalPoint; 00592 00593 protected: 00594 00595 /* 00596 * Number of parameters */ 00597 int fMCMCNParameters; 00598 00599 /* 00600 * Parameter boundaries */ 00601 std::vector <double> fMCMCBoundaryMin; 00602 std::vector <double> fMCMCBoundaryMax; 00603 00604 /* 00605 * Number of Markov chains ran in parallel */ 00606 int fMCMCNChains; 00607 00608 /* 00609 * Number of total iterations of the Markov chains. The length of 00610 * the vector is equal to fMCMCNChains. */ 00611 std::vector<int> fMCMCNIterations; 00612 00613 /* 00614 * Number of iterations for updating scale factors */ 00615 int fMCMCNIterationsUpdate; 00616 00617 /* 00618 * Number of iterations needed for each chain to convergence. The 00619 * size of the vector is equal to fMCMCNChains. */ 00620 std::vector<int> fMCMCNIterationsConvergenceLocal; 00621 00622 /* 00623 * Number of iterations needed for all chains to convergence simulaneously */ 00624 int fMCMCNIterationsConvergenceGlobal; 00625 00626 /* 00627 * Flag for convergence */ 00628 bool fMCMCFlagConvergenceGlobal; 00629 00630 /* 00631 * Maximum number of iterations for a Markov chain prerun */ 00632 int fMCMCNIterationsMax; 00633 00634 /* 00635 * Number of iterations for a Markov chain run */ 00636 int fMCMCNIterationsRun; 00637 00638 /* 00639 * Minimum number of iterations for the pre-run */ 00640 int fMCMCNIterationsPreRunMin; 00641 00642 /* 00643 * Number of iterations for burn-in. These iterations are not 00644 * included in fMCMCNIterations. */ 00645 int fMCMCNIterationsBurnIn; 00646 00647 /* 00648 * Number of iterations for PCA. These iterations are not included 00649 * in FMCMCNIterations. */ 00650 int fMCMCNIterationsPCA; 00651 00652 /* 00653 * Mean values of the data in the PCA coordinate system */ 00654 std::vector <double> fMCMCPCAMean; 00655 00656 /* 00657 * Variance of the data in the PCA coordinate system */ 00658 std::vector <double> fMCMCPCAVariance; 00659 00660 /* 00661 * Flag to control if during the PCA the least eigenvectors should 00662 * be ignored or not */ 00663 bool fMCMCFlagPCATruncate; 00664 00665 /* 00666 * Minimum ratio of an eigenvalue to the largest eigenvalue below 00667 * which it is ignored if fMCMCFlagPCATruncate is true */ 00668 double fMCMCPCAMinimumRatio; 00669 00670 /* 00671 * If the least eigenvectors are ignored this is the number of 00672 * dimensions remaining */ 00673 int fMCMCNDimensionsPCA; 00674 00675 /* 00676 * Number of accepted trials and not accepted trials for each 00677 * chain. The length of the vectors is equal to fMCMCNChains * 00678 * fMCMCNParameters. For each chain these numbers add up to 00679 * fMCMCNIterations. */ 00680 std::vector<int> fMCMCNTrialsTrue; 00681 std::vector<int> fMCMCNTrialsFalse; 00682 00683 /* 00684 * The mean and variance of all values of each Markov chain. The 00685 * length of the vectors is equal to fMCMCNChains. */ 00686 std::vector <double> fMCMCMean; 00687 std::vector <double> fMCMCVariance; 00688 00689 /* 00690 * The sum and sum squared of all values of each Markov chain. These 00691 * are used to calculate the mean and variance of each chain. The 00692 * length of the vectors is equal to fMCMCNChains. */ 00693 std::vector <double> fMCMCSum; 00694 std::vector <double> fMCMCSum2; 00695 00696 /* 00697 * The mean and variance of all parameters of each Markov chain. The 00698 * length of the vectors is equal to fMCMCNChains * fMCMCNParameters. */ 00699 std::vector <double> fMCMCMeanx; 00700 std::vector <double> fMCMCVariancex; 00701 00702 /* 00703 * Flag to automatically calculate the number of iterations of a 00704 * Markov chain */ 00705 bool fMCMCFlagIterationsAuto; 00706 00707 /* 00708 * Flag to write Markov chains to file */ 00709 bool fMCMCFlagWriteChainToFile; 00710 00711 /* 00712 * Scales the width of the trial functions by a global factor */ 00713 double fMCMCTrialFunctionScale; 00714 00715 /* 00716 * Scales the width of the trial functions by a scale factor 00717 * for each parameter and chain */ 00718 std::vector <double> fMCMCTrialFunctionScaleFactor; 00719 std::vector <double> fMCMCTrialFunctionScaleFactorStart; 00720 00721 /* 00722 * Defines if a prerun has been performed or not */ 00723 bool fMCMCFlagPreRun; 00724 00725 /* 00726 * The intial position of each Markov chain. The length of the 00727 * vectors is equal to fMCMCNChains * fMCMCNParameters. First, the 00728 * values of the first Markov chain are saved, then those of the 00729 * second and so on */ 00730 std::vector <double> fMCMCInitialPosition; 00731 00732 /* 00733 * Minimum efficiency for MCMC */ 00734 double fMCMCEfficiencyMin; 00735 00736 /* 00737 * Maximum efficiency for MCMC */ 00738 double fMCMCEfficiencyMax; 00739 00740 /* 00741 * Variable which defines the initial position. 0 (default) center 00742 * of the allowed region, (1) random initial position (2) 00743 * pre-defined intial position. */ 00744 int fMCMCFlagInitialPosition; 00745 00746 /* 00747 * Flag which controls the sequence parameters during the running 00748 * of the MCMC. */ 00749 bool fMCMCFlagOrderParameters; 00750 00751 /* 00752 * The current points of each Markov chain. The length of the 00753 * vectors is equal to fMCMCNChains * fMCMCNParameters. First, the 00754 * values of the first Markov chain are saved, then those of the 00755 * second and so on. */ 00756 std::vector <double> fMCMCx; 00757 00758 /* 00759 * A temporary vector for a single Markov chain */ 00760 std::vector <double> fMCMCxLocal; 00761 00762 /* 00763 * The log of the probability of the current points of each Markov 00764 * chain. The length of the vectors is fMCMCNChains. */ 00765 std::vector<double> fMCMCLogProbx; 00766 00767 /* 00768 * The maximum points of each Markov chain. The length of the vector 00769 * is fMCMCNChains * fMCMCNParameters. First, the values of the 00770 * first Markov chain are saved, then those of the second and so on. */ 00771 std::vector <double> fMCMCMaximumPoints; 00772 00773 /* 00774 * The maximum (log) probability of each Markov chain. The length of 00775 * the vector is fMCMCNChains. */ 00776 std::vector <double> fMCMCMaximumLogProb; 00777 00778 /* 00779 * The R-value criterion for convergence of log-likelihood*/ 00780 double fMCMCRValueCriterion; 00781 00782 /* 00783 * The R-value criterion for convergence of parameters */ 00784 double fMCMCRValueParametersCriterion; 00785 00786 /* 00787 * The R-value at which the chains did converge */ 00788 double fMCMCRValue; 00789 00790 std::vector <double> fMCMCRValueParameters; 00791 00792 /* 00793 * The relative precision for the convergence of the modes of 00794 * several chains */ 00795 // double fMCMCRelativePrecisionMode; 00796 00797 // std::vector <double> fMCMCRelativePrecisionModeValues; 00798 std::vector <double> fMCMCNumericalPrecisionModeValues; 00799 00800 /* 00801 * Random number generator */ 00802 TRandom3 * fMCMCRandom; 00803 00804 /* 00805 * PCA */ 00806 TPrincipal * fMCMCPCA; 00807 00808 /* 00809 * Flag to perform PCA or not */ 00810 bool fMCMCFlagPCA; 00811 00812 /* 00813 * Number of bins per dimension for the marginalized distributions. */ 00814 std::vector<int> fMCMCH1NBins; 00815 00816 /* 00817 * An array of marginalized distributions */ 00818 std::vector <TH1D *> fMCMCH1Marginalized; 00819 std::vector <TH2D *> fMCMCH2Marginalized; 00820 00821 /* 00822 * Control plots */ 00823 // TH1D * fMCMCH1RValue; // R-value 00824 // TH1D * fMCMCH1Efficiency; // Efficiency of the Markov chain 00825 00826 /* 00827 * The trees containing the Markov chains. The length of the vector 00828 * is fMCMCNChains. */ 00829 std::vector<TTree *> fMCMCTrees; 00830 }; 00831 00832 // --------------------------------------------------------- 00833 00834 #endif