CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
CombinedDistribution.h
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2021 by Federico Marulli and Sofia Contarini *
3  * federico.marulli3@unibo.it *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public *
16  * License along with this program; if not, write to the Free *
17  * Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ********************************************************************/
20 
33 #ifndef __COMBDISTR__
34 #define __COMBDISTR__
35 
36 #include "Distribution.h"
37 #include "EigenWrapper.h"
38 #include "ChainMesh.h"
39 
40 // ===================================================================================================
41 
42 
43 namespace cbl {
44 
45  namespace glob {
46 
54  class CombinedDistribution : public Distribution {
55 
56  protected:
57 
59  std::vector<std::shared_ptr<Distribution>> m_distributionVec;
60 
62  std::vector<double> m_xMinVec;
63 
65  std::vector<double> m_xMaxVec;
66 
68  std::shared_ptr<void> m_inputs;
69 
72 
73  public:
74 
79 
83  CombinedDistribution () : Distribution () {}
84 
93  CombinedDistribution (const glob::DistributionType priorType, const double value) : Distribution(priorType, value) {}
94 
107  CombinedDistribution (const glob::DistributionType priorType, const double xmin, const double xmax, const int seed=1)
108  : Distribution(priorType, xmin, xmax, seed) {}
109 
125  CombinedDistribution (const glob::DistributionType priorType, const std::vector<double> prior_params, const double xmin, const double xmax, const int seed=1)
126  : Distribution(priorType, prior_params, xmin, xmax, seed) {}
127 
146  CombinedDistribution (const glob::DistributionType priorType, const distribution_func prior_func, const std::shared_ptr<void> prior_fixed_pars, const std::vector<double> prior_pars, const double xmin, const double xmax, const int seed=1)
147  : Distribution(priorType, prior_func, prior_fixed_pars, prior_pars, xmin, xmax, seed) {}
148 
161  CombinedDistribution (const glob::DistributionType priorType, const std::vector<double> discrete_values, const std::vector<double> weights, const int seed=1)
162  : Distribution(priorType, discrete_values, weights, seed) {}
163 
180  CombinedDistribution (const glob::DistributionType priorType, const std::vector<double> var, const std::vector<double> dist, const int nbin, const std::string interpolationType, const int seed=1)
181  : Distribution(priorType, var, dist, nbin, interpolationType, seed) {}
182 
200  CombinedDistribution (const DistributionType distributionType, const std::vector<double> meanVec, const std::vector<std::vector<double>> covMat, const std::vector<double> xMinVec, const std::vector<double> xMaxVec, const int seed=3213);
201 
234  CombinedDistribution (const std::string filename, const std::string path, const std::vector<int> columns_to_read, const int skip_nlines=0, const int type_data=0, const bool normalize=true, const int distNum=200, const double rMAX=2, const double cell_size=2);
235 
239  ~CombinedDistribution () = default;
240 
242 
250  double operator [] (std::vector<double> xx);
251 
260  std::shared_ptr<Distribution> get_distribution (int i) {return m_distributionVec[i];}
261 
267  size_t get_size_distribution () {return m_distributionVec.size();}
268 
269  };
270  }
271 }
272 
273 #endif
Implementation of the chain-mesh data structure.
The class Distribution.
functions that wrap Eigen routines
The class CombinedDistribution.
Definition: Distribution.h:124
DistributionType
the distribution type
Definition: Distribution.h:51
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
std::function< double(std::vector< double >, std::shared_ptr< void >)> nDim_distribution_func
distribution function used for a n-dimensional distribution
Definition: RandomNumbers.h:57
std::function< double(double, std::shared_ptr< void >, std::vector< double >)> distribution_func
generic distribution function
Definition: RandomNumbers.h:50