![]() |
MaCh3 2.2.1
Reference Guide
|
Class responsible for handling Principal Component Analysis (PCA) of covariance matrix. More...
#include <Parameters/PCAHandler.h>
Public Member Functions | |
PCAHandler () | |
Constructor. | |
virtual | ~PCAHandler () |
Destructor. | |
void | Print () |
KS: Print info about PCA parameters. | |
int | GetNumberPCAedParameters () const |
Retrieve number of parameters in PCA base. | |
void | SetupPointers (std::vector< double > *fCurr_Val, std::vector< double > *fProp_Val) |
KS: Setup pointers to current and proposed parameter value which we need to convert them to PCA base each step. | |
void | ConstructPCA (TMatrixDSym *CovMatrix, const int firstPCAd, const int lastPCAd, const double eigen_thresh, const int _fNumPar) |
CW: Calculate eigen values, prepare transition matrices and remove param based on defined threshold. | |
void | TransferToPCA () |
Transfer param values from normal base to PCA base. | |
void | TransferToParam () |
Transfer param values from PCA base to normal base. | |
void | ThrowParameters (const std::vector< std::unique_ptr< TRandom3 > > &random_number, double **throwMatrixCholDecomp, double *randParams, double *corr_throw, const std::vector< double > &fPreFitValue, const std::vector< double > &fLowBound, const std::vector< double > &fUpBound, int _fNumPar) |
Throw the parameters according to the covariance matrix. This shouldn't be used in MCMC code ase it can break Detailed Balance;. | |
void | AcceptStep () _noexcept_ |
Accepted this step. | |
void | CorrelateSteps (const std::vector< double > &IndivStepScale, const double GlobalStepScale, const double *_restrict_ randParams, const double *_restrict_ corr_throw) _noexcept_ |
Use Cholesky throw matrix for better step proposal. | |
void | SetInitialParameters (std::vector< double > &IndStepScale) |
KS: Transfer the starting parameters to the PCA basis, you don't want to start with zero.. | |
void | ThrowParProp (const double mag, const double *_restrict_ randParams) |
Throw the proposed parameter by mag sigma. | |
void | ThrowParCurr (const double mag, const double *_restrict_ randParams) |
Helper function to throw the current parameter by mag sigma. | |
void | SetBranches (TTree &tree, bool SaveProposal, const std::vector< std::string > &Names) |
set branches for output file | |
void | ToggleFixAllParameters () |
fix parameters at prior values | |
void | ToggleFixParameter (const int i, const std::vector< std::string > &Names) |
fix parameters at prior values | |
void | SetParametersPCA (const std::vector< double > &pars) |
Set values for PCA parameters in PCA base. | |
bool | IsParameterFixedPCA (const int i) const |
Is parameter fixed in PCA base or not. | |
const TMatrixD | GetEigenVectors () const |
Get eigen vectors of covariance matrix, only works with PCA. | |
void | SetParPropPCA (const int i, const double value) |
Set proposed value for parameter in PCA base. | |
void | SetParCurrPCA (const int i, const double value) |
Set current value for parameter in PCA base. | |
double | GetParPropPCA (const int i) const |
Get current parameter value using PCA. | |
double | GetPreFitValuePCA (const int i) const |
Get current parameter value using PCA. | |
double | GetParCurrPCA (const int i) const |
Get current parameter value using PCA. | |
const TMatrixD | GetTransferMatrix () const |
Get transfer matrix allowing to go from PCA base to normal base. | |
const TVectorD | GetEigenValues () const |
Get eigen values for all parameters, if you want for decomposed only parameters use GetEigenValuesMaster. | |
const std::vector< double > | GetEigenValuesMaster () const |
Get eigen value of only decomposed parameters, if you want for all parameters use GetEigenValues. | |
bool | IsParameterDecomposed (const int i) const |
Check if parameter in PCA base is decomposed or not. | |
Private Member Functions | |
void | SanitisePCA (TMatrixDSym *CovMatrix) |
@biref KS: Make sure decomposed matrix isn't correlated with undecomposed | |
Private Attributes | |
std::vector< double > | _fPreFitValuePCA |
Prefit value for PCA params. | |
TVectorD | _fParPropPCA |
CW: Current parameter value in PCA base. | |
TVectorD | _fParCurrPCA |
CW: Proposed parameter value in PCA base. | |
std::vector< double > | _fErrorPCA |
Tells if parameter is fixed in PCA base or not. | |
std::vector< int > | isDecomposedPCA |
If param is decomposed this will return -1, if not this will return enumerator to param in normal base. This way we can map stuff like step scale etc between normal base and undecomposed param in eigen base. | |
int | NumParPCA |
Number of parameters in PCA base. | |
TMatrixD | TransferMat |
Matrix used to converting from PCA base to normal base. | |
TMatrixD | TransferMatT |
Matrix used to converting from normal base to PCA base. | |
TVectorD | eigen_values |
Eigen value only of particles which are being decomposed. | |
TMatrixD | eigen_vectors |
Eigen vectors only of params which are being decomposed. | |
std::vector< double > | eigen_values_master |
Eigen values which have dimension equal to _fNumParPCA, and can be used in CorrelateSteps. | |
int | nKeptPCApars |
Total number that remained after applying PCA Threshold. | |
int | FirstPCAdpar |
Index of the first param that is being decomposed. | |
int | LastPCAdpar |
Index of the last param that is being decomposed. | |
double | eigen_threshold |
CW: Threshold based on which we remove parameters in eigen base. | |
std::vector< double > * | _pCurrVal |
Pointer to current value of the parameter. | |
std::vector< double > * | _pPropVal |
Pointer to proposed value of the parameter. | |
Class responsible for handling Principal Component Analysis (PCA) of covariance matrix.
Definition at line 30 of file PCAHandler.h.
PCAHandler::PCAHandler | ( | ) |
Constructor.
Definition at line 5 of file PCAHandler.cpp.
|
virtual |
Destructor.
Definition at line 12 of file PCAHandler.cpp.
void PCAHandler::AcceptStep | ( | ) |
Accepted this step.
Definition at line 183 of file PCAHandler.cpp.
void PCAHandler::ConstructPCA | ( | TMatrixDSym * | CovMatrix, |
const int | firstPCAd, | ||
const int | lastPCAd, | ||
const double | eigen_thresh, | ||
const int | _fNumPar | ||
) |
CW: Calculate eigen values, prepare transition matrices and remove param based on defined threshold.
CovMatrix | Symmetric covariance matrix used for eigen decomposition. |
firstPCAd | Index of the first PCA component to include. |
lastPCAd | Index of the last PCA component to include. |
eigen_thresh | Threshold for eigenvalues below which parameters are discarded. |
_fNumPar | Total number of parameters in the original (non-PCA) basis. |
Definition at line 26 of file PCAHandler.cpp.
void PCAHandler::CorrelateSteps | ( | const std::vector< double > & | IndivStepScale, |
const double | GlobalStepScale, | ||
const double *_restrict_ | randParams, | ||
const double *_restrict_ | corr_throw | ||
) |
Use Cholesky throw matrix for better step proposal.
Definition at line 198 of file PCAHandler.cpp.
|
inline |
void PCAHandler::Print | ( | ) |
KS: Print info about PCA parameters.
Definition at line 303 of file PCAHandler.cpp.
|
private |
@biref KS: Make sure decomposed matrix isn't correlated with undecomposed
Definition at line 154 of file PCAHandler.cpp.
void PCAHandler::SetInitialParameters | ( | std::vector< double > & | IndStepScale | ) |
KS: Transfer the starting parameters to the PCA basis, you don't want to start with zero..
IndStepScale | Per parameter step scale, we set so each PCA param uses same step scale [eigen value takes care of size] |
Definition at line 249 of file PCAHandler.cpp.
void PCAHandler::SetupPointers | ( | std::vector< double > * | fCurr_Val, |
std::vector< double > * | fProp_Val | ||
) |
KS: Setup pointers to current and proposed parameter value which we need to convert them to PCA base each step.
fCurr_Val | pointer to current position of parameter |
fProp_Val | pointer to proposed position of parameter |
Definition at line 18 of file PCAHandler.cpp.
void PCAHandler::ThrowParameters | ( | const std::vector< std::unique_ptr< TRandom3 > > & | random_number, |
double ** | throwMatrixCholDecomp, | ||
double * | randParams, | ||
double * | corr_throw, | ||
const std::vector< double > & | fPreFitValue, | ||
const std::vector< double > & | fLowBound, | ||
const std::vector< double > & | fUpBound, | ||
int | _fNumPar | ||
) |
Throw the parameters according to the covariance matrix. This shouldn't be used in MCMC code ase it can break Detailed Balance;.
Definition at line 352 of file PCAHandler.cpp.
void PCAHandler::ThrowParCurr | ( | const double | mag, |
const double *_restrict_ | randParams | ||
) |
Helper function to throw the current parameter by mag sigma.
Definition at line 292 of file PCAHandler.cpp.
void PCAHandler::ThrowParProp | ( | const double | mag, |
const double *_restrict_ | randParams | ||
) |
Throw the proposed parameter by mag sigma.
Definition at line 280 of file PCAHandler.cpp.
void PCAHandler::TransferToParam | ( | ) |
Transfer param values from PCA base to normal base.
Definition at line 264 of file PCAHandler.cpp.
void PCAHandler::TransferToPCA | ( | ) |
Transfer param values from normal base to PCA base.
Definition at line 234 of file PCAHandler.cpp.
|
private |
Tells if parameter is fixed in PCA base or not.
Definition at line 209 of file PCAHandler.h.
|
private |
CW: Proposed parameter value in PCA base.
Definition at line 207 of file PCAHandler.h.
|
private |
CW: Current parameter value in PCA base.
Definition at line 205 of file PCAHandler.h.
|
private |
Prefit value for PCA params.
Definition at line 203 of file PCAHandler.h.
|
private |
Pointer to current value of the parameter.
Definition at line 236 of file PCAHandler.h.
|
private |
Pointer to proposed value of the parameter.
Definition at line 238 of file PCAHandler.h.
|
private |
CW: Threshold based on which we remove parameters in eigen base.
Definition at line 233 of file PCAHandler.h.
|
private |
Eigen value only of particles which are being decomposed.
Definition at line 220 of file PCAHandler.h.
|
private |
Eigen values which have dimension equal to _fNumParPCA, and can be used in CorrelateSteps.
Definition at line 224 of file PCAHandler.h.
|
private |
Eigen vectors only of params which are being decomposed.
Definition at line 222 of file PCAHandler.h.
|
private |
Index of the first param that is being decomposed.
Definition at line 229 of file PCAHandler.h.
|
private |
If param is decomposed this will return -1, if not this will return enumerator to param in normal base. This way we can map stuff like step scale etc between normal base and undecomposed param in eigen base.
Definition at line 211 of file PCAHandler.h.
|
private |
Index of the last param that is being decomposed.
Definition at line 231 of file PCAHandler.h.
|
private |
Total number that remained after applying PCA Threshold.
Definition at line 227 of file PCAHandler.h.
|
private |
Number of parameters in PCA base.
Definition at line 213 of file PCAHandler.h.
|
private |
Matrix used to converting from PCA base to normal base.
Definition at line 216 of file PCAHandler.h.
|
private |
Matrix used to converting from normal base to PCA base.
Definition at line 218 of file PCAHandler.h.