CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
prior.cpp

This example shows how to menage priors

// ======================================
// Example code: how to construct a prior
// ======================================
int main () {
try {
double xmin = -10., xmax = 10.;
double mean = -1., sigma = 0.1;
cbl::statistics::PriorDistribution priorDistribution { cbl::glob::DistributionType::_Gaussian_, {mean, sigma}, xmin, xmax };
for (int i=0; i<100; ++i) {
double value = priorDistribution.sample();
std::cout << i << " " << value << " " << priorDistribution(value) << std::endl;
}
}
catch(cbl::glob::Exception &exc) { std::cerr << exc.what() << std::endl; exit(1); }
return 0;
}
int main()
main function to create the logo of the CosmoBolognaLib
Definition: Logo.cpp:41
The class PriorDistribution.
The class Exception.
Definition: Exception.h:111
const char * what() const noexcept override
the error description
Definition: Exception.h:203
The class PriorDistribution.
@ _Gaussian_
Gaussian function.