BornAgain  1.19.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 reflection and scattering
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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_PARAM_DISTRIB_DISTRIBUTIONHANDLER_H
21 #define BORNAGAIN_PARAM_DISTRIB_DISTRIBUTIONHANDLER_H
22 
24 #include <vector>
25 
26 //! Provides the functionality to average over parameter distributions with weights.
27 
28 //! @ingroup algorithms_internal
30 public:
31  typedef std::vector<ParameterDistribution> Distributions_t;
34 
35  //! add a sampled parameter distribution
36  void addParameterDistribution(const std::string& param_name,
37  const IDistribution1D& distribution, size_t nbr_samples,
38  double sigma_factor = 0.0,
39  const RealLimits& limits = RealLimits());
40 
41  void addParameterDistribution(const ParameterDistribution& par_distr);
42 
43  //! get the total number of parameter value combinations (product
44  //! of the individual sizes of each parameter distribution
45  size_t getTotalNumberOfSamples() const;
46 
47  //! set the parameter values of the simulation object to a specific
48  //! combination of values, determined by the index (which must be smaller
49  //! than the total number of combinations) and returns the weight
50  //! associated with this combination of parameter values
51  double setParameterValues(ParameterPool* p_parameter_pool, size_t index);
52 
53  //! Sets mean distribution values to the parameter pool.
54  void setParameterToMeans(ParameterPool* p_parameter_pool) const;
55 
56  const Distributions_t& getDistributions() const;
57 
58 private:
61  std::vector<std::vector<ParameterSample>> m_cached_samples;
62 };
63 
64 #endif // BORNAGAIN_PARAM_DISTRIB_DISTRIBUTIONHANDLER_H
65 #endif // USER_API
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:34
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 IParametricComponent object.
Definition: ParameterPool.h:29
Limits for a real fit parameter.
Definition: RealLimits.h:24