This example shows how to generate random numbers extracted from a generic probability distribution
try {
const cbl::distribution_func func = [] (
double x,
const std::shared_ptr<void> modelInput, std::vector<double> parameter)
{
const std::vector<double> data = *std::static_pointer_cast<std::vector<double>>(modelInput);
return 1./(parameter[1]*data[0])*exp(-data[1]*pow((x-parameter[0])/parameter[1], 2));
};
const std::vector<double> vect = {sqrt(2.*
cbl::par::pi), 0.5};
auto data = std::make_shared<std::vector<double>>(vect);
const std::vector<double> parameter = {0., 0.1};
for (int i=0; i<10; ++i) std::cout << ran1() << " " << ran1() << std::endl;
}
return 0;
}
Class used to handle binned variables.
int main()
main function to create the logo of the CosmoBolognaLib
Class functions used to generate random numbers.
const char * what() const noexcept override
the error description
The class CustomDistributionRandomNumbers.
static const double pi
: the ratio of a circle's circumference to its diameter
std::function< double(double, std::shared_ptr< void >, std::vector< double >)> distribution_func
generic distribution function