BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
Provides the functionality to average over parameter distributions with weights.
Definition at line 29 of file DistributionHandler.h.
Public Member Functions | |
DistributionHandler () | |
virtual | ~DistributionHandler () |
void | addParameterDistribution (const ParameterDistribution &par_distr) |
void | addParameterDistribution (const std::string ¶m_name, const IDistribution1D &distribution, size_t nbr_samples, double sigma_factor=0.0, const RealLimits &limits=RealLimits()) |
add a sampled parameter distribution More... | |
void | defineCallbackForDistribution (const ParameterDistribution *distribution, std::function< void(double)> fn) |
const std::vector< ParameterDistribution > & | getDistributions () const |
size_t | getTotalNumberOfSamples () const |
get the total number of parameter value combinations (product of the individual sizes of each parameter distribution More... | |
double | setParameterValues (size_t index) |
set the parameter values of the simulation object to a specific combination of values, determined by the index (which must be smaller than the total number of combinations) and returns the weight associated with this combination of parameter values. initParameterLinks() has to be called before this! More... | |
Private Attributes | |
std::vector< std::vector< ParameterSample > > | m_cached_samples |
std::vector< ParameterDistribution > | m_distributions |
size_t | m_nbr_combinations |
std::map< const ParameterDistribution *, std::function< void(double)> > | m_setValueFunctions |
DistributionHandler::DistributionHandler | ( | ) |
Definition at line 19 of file DistributionHandler.cpp.
|
virtualdefault |
void DistributionHandler::addParameterDistribution | ( | const ParameterDistribution & | par_distr | ) |
Definition at line 26 of file DistributionHandler.cpp.
References ParameterDistribution::generateSamples(), m_cached_samples, m_distributions, m_nbr_combinations, and ParameterDistribution::nDraws().
void DistributionHandler::addParameterDistribution | ( | const std::string & | param_name, |
const IDistribution1D & | distribution, | ||
size_t | nbr_samples, | ||
double | sigma_factor = 0.0 , |
||
const RealLimits & | limits = RealLimits() |
||
) |
add a sampled parameter distribution
Referenced by ISimulation::addParameterDistribution().
void DistributionHandler::defineCallbackForDistribution | ( | const ParameterDistribution * | distribution, |
std::function< void(double)> | fn | ||
) |
Definition at line 69 of file DistributionHandler.cpp.
References m_setValueFunctions.
Referenced by ISimulation2D::initDistributionHandler().
const std::vector< ParameterDistribution > & DistributionHandler::getDistributions | ( | ) | const |
Definition at line 64 of file DistributionHandler.cpp.
References m_distributions.
Referenced by ISimulation::getDistributions(), and ISimulation2D::initDistributionHandler().
size_t DistributionHandler::getTotalNumberOfSamples | ( | ) | const |
get the total number of parameter value combinations (product of the individual sizes of each parameter distribution
Definition at line 35 of file DistributionHandler.cpp.
References m_nbr_combinations.
Referenced by ISimulation::simulate().
double DistributionHandler::setParameterValues | ( | size_t | index | ) |
set the parameter values of the simulation object to a specific combination of values, determined by the index (which must be smaller than the total number of combinations) and returns the weight associated with this combination of parameter values. initParameterLinks() has to be called before this!
Definition at line 40 of file DistributionHandler.cpp.
References ASSERT, m_cached_samples, m_distributions, m_nbr_combinations, and m_setValueFunctions.
Referenced by ISimulation::simulate().
|
private |
Definition at line 62 of file DistributionHandler.h.
Referenced by addParameterDistribution(), and setParameterValues().
|
private |
Definition at line 60 of file DistributionHandler.h.
Referenced by addParameterDistribution(), getDistributions(), and setParameterValues().
|
private |
Definition at line 59 of file DistributionHandler.h.
Referenced by addParameterDistribution(), getTotalNumberOfSamples(), and setParameterValues().
|
private |
Definition at line 61 of file DistributionHandler.h.
Referenced by defineCallbackForDistribution(), and setParameterValues().