CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Prior.cpp
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2014 by Federico Marulli and Alfonso Veropalumbo *
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 #include "Prior.h"
34 
35 using namespace std;
36 
37 using namespace cbl;
38 
39 
40 // ============================================================================================
41 
42 
43 cbl::statistics::Prior::Prior (const Prior_function prior_function, const std::shared_ptr<void> prior_function_inputs)
44 {
45  m_prior_function = prior_function;
46  m_prior_function_inputs = prior_function_inputs;
47 }
48 
49 
50 // ============================================================================================
51 
52 
53 double cbl::statistics::Prior::operator () (const vector<double> parameters)
54 {
55  return m_prior_function(parameters, m_prior_function_inputs);
56 }
57 
58 
59 // ============================================================================================
60 
61 
62 double cbl::statistics::Prior::log (const vector<double> parameter)
63 {
64  double prior = this->operator()(parameter);
65  return (prior>0) ? std::log(prior) : par::defaultDouble;
66 }
The class Prior.
double operator()(const std::vector< double > parameters)
Definition: Prior.cpp:53
double log(const std::vector< double > parameter)
compute the logarithm of the prior for the input parameters
Definition: Prior.cpp:62
Prior()
default constructor
Definition: Prior.h:81
static const double defaultDouble
default double value
Definition: Constants.h:348
std::function< double(const std::vector< double >, const std::shared_ptr< void >)> Prior_function
definition of a function for computation of the Prior
Definition: Prior.h:50
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38