BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DistributionHandler.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Param/Distrib/DistributionHandler.h
6 //! @brief Defines class DistributionHandler.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_CORE_PARAMETRIZATION_DISTRIBUTIONHANDLER_H
16 #define BORNAGAIN_CORE_PARAMETRIZATION_DISTRIBUTIONHANDLER_H
17 
19 #include <vector>
20 
21 //! Provides the functionality to average over parameter distributions with weights.
22 
23 //! @ingroup algorithms_internal
25 {
26 public:
27  typedef std::vector<ParameterDistribution> Distributions_t;
30 
31  //! add a sampled parameter distribution
32  void addParameterDistribution(const std::string& param_name,
33  const IDistribution1D& distribution, size_t nbr_samples,
34  double sigma_factor = 0.0,
35  const RealLimits& limits = RealLimits());
36 
37  void addParameterDistribution(const ParameterDistribution& par_distr);
38 
39  //! get the total number of parameter value combinations (product
40  //! of the individual sizes of each parameter distribution
41  size_t getTotalNumberOfSamples() const;
42 
43  //! set the parameter values of the simulation object to a specific
44  //! combination of values, determined by the index (which must be smaller
45  //! than the total number of combinations) and returns the weight
46  //! associated with this combination of parameter values
47  double setParameterValues(ParameterPool* p_parameter_pool, size_t index);
48 
49  //! Sets mean distribution values to the parameter pool.
50  void setParameterToMeans(ParameterPool* p_parameter_pool) const;
51 
52  const Distributions_t& getDistributions() const;
53 
54 private:
57  std::vector<std::vector<ParameterSample>> m_cached_samples;
58 };
59 
60 #endif // BORNAGAIN_CORE_PARAMETRIZATION_DISTRIBUTIONHANDLER_H
Defines class ParameterDistribution.
Provides the functionality to average over parameter distributions with weights.
Distributions_t m_distributions
void 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
const Distributions_t & getDistributions() const
virtual ~DistributionHandler()
double setParameterValues(ParameterPool *p_parameter_pool, size_t index)
set the parameter values of the simulation object to a specific combination of values,...
std::vector< ParameterDistribution > Distributions_t
void setParameterToMeans(ParameterPool *p_parameter_pool) const
Sets mean distribution values to the parameter pool.
size_t getTotalNumberOfSamples() const
get the total number of parameter value combinations (product of the individual sizes of each paramet...
std::vector< std::vector< ParameterSample > > m_cached_samples
Interface for one-dimensional distributions.
Definition: Distributions.h:33
Manages a local parameter pool, and a tree of child pools.
A parametric distribution function, for use with any model parameter.
Container with parameters for IParameterized object.
Definition: ParameterPool.h:30
Limits for a real fit parameter.
Definition: RealLimits.h:25