CentralValuesAndUncertainties.h
Go to the documentation of this file.
1 #ifndef CENTRALVALUESANDUNCERTAINTIES_H
2 #define CENTRALVALUESANDUNCERTAINTIES_H
3 
4 #include <utility>
5 #include <map>
6 #include <vector>
7 #include "ParameterTable.h"
8 #include "TMatrixD.h"
9 #include "TVectorD.h"
10 #include <TDecompChol.h>
11 //#include "MatrixClass.h"
12 
13 class TRandom3;
14 
15 namespace NeutrinoFluxReweight{
16 
17  /*! \class CentralValuesAndUncertainties
18  * \brief A class to manage parameter central values and their uncertanities
19  */
21  public:
22 
25 
26  //! Read a xml file name to parse the parameters.
27  void readFromXML(const char* filename);
28 
29  //! Add a parameter with its central value and its uncertainty. The parameter is specified as uncorrelated with all other parameters in the table, and any others that will be added. In that case, the uncertainty can be represented as a single floating point value.
30  void addUncorrelated(Parameter& cv_par, double uncertainty);
31 
32  //!Add a set of parameters with correlated uncertainties. The central values of the parameters must be provided along with the covariance matrix of the parameters. These parameters are assumed to be block uncorrelated with all the other parameters.
33 
34  // void addCorrelated(ParameterTable& cv_pars, MatrixClass& cov_mx);
35  void addCorrelated(ParameterTable& cv_pars, TMatrixD& cov_mx);
36 
37  //!Set a beggining/base seed to be used in generating random parameter shifts for the many universe method. This base seed should be unique and not shared by any other many universe error calculator.
38  void setBaseSeed(int val);
39 
40  //! Calculate a table of randomly varied parameters for a particular universe i. The universe number is used, along with the base seed, to calculate a unique seed for this universe, allowing our computation to be repeatable. We loop over all uncorrelated parameters and sample each from a normal distribution with mean=CV parameter and variance=sqrate of the uncertainty. We loop over all correlated sets of parameters. For each, we have a list of N central values x and a single joint NxN covariance matrix V. We execute a cholesky decomposition of V to find a lower left diagonal matrix L such that L L^T =V. Then we generate
42 
43  //!Get the central value parameters.
45 
46  private:
48  //for now commenting out: ParameterTable& uncorrelated_pars;
50  boost::interprocess::flat_map<std::string, double> uncorrelated_errors;
51  std::vector<ParameterTable> correlated_par_tables;
52  std::vector<TMatrixD> covariance_matrices;
53  TRandom3 *r3;
54  int baseSeed;
55 
56  };
57 
58 
59 
60 }
61 #endif
A list/table of parameter names and values.
std::pair< std::string, double > Parameter
string filename
Definition: train.py:213
ParameterTable calculateParsForUniverse(int universe)
Calculate a table of randomly varied parameters for a particular universe i. The universe number is u...
void addUncorrelated(Parameter &cv_par, double uncertainty)
Add a parameter with its central value and its uncertainty. The parameter is specified as uncorrelate...
boost::interprocess::flat_map< std::string, double > uncorrelated_errors
A class to manage parameter central values and their uncertanities.
ParameterTable getCVPars()
Get the central value parameters.
void addCorrelated(ParameterTable &cv_pars, TMatrixD &cov_mx)
Add a set of parameters with correlated uncertainties. The central values of the parameters must be p...
void readFromXML(const char *filename)
Read a xml file name to parse the parameters.
void setBaseSeed(int val)
Set a beggining/base seed to be used in generating random parameter shifts for the many universe meth...