9#ifndef __DISCRETE_DISTRIBUTION_H_INCLUDED__
10#define __DISCRETE_DISTRIBUTION_H_INCLUDED__
35 std::vector<State> m_support;
36 std::vector<double> m_weights;
41 Param() : m_support(std::vector<State>(1)), m_weights(std::vector<double>(1, 1.0))
45 Param(Param
const &other) =
default;
47 Param(std::vector<State>
const &support, std::vector<double>
const &weights)
48 : m_support(support), m_weights(weights)
52 Param(std::vector<State> &&support, std::vector<double> &&weights)
53 : m_support(std::move(support)), m_weights(std::move(weights))
57 Param &operator=(Param
const &other) =
default;
59 bool operator==(Param
const &other)
61 return (m_support == other.m_support && m_weights == other.m_weights);
64 std::vector<State>
const &support()
const
69 std::vector<double>
const &weights()
const
78 using result_type = State;
82 using param_type = Param;
108 : m_param(support, weights)
115 : m_param(std::move(support), std::move(weights))
131 template <
typename Generator> result_type
operator()(Generator &g)
const
133 std::discrete_distribution<int> d(m_param.weights().cbegin(), m_param.weights().cend());
134 return m_param.support()[d(g)];
143 template <
typename Generator> result_type
operator()(Generator &g,
const param_type ¶ms)
const
145 std::discrete_distribution<int> d(params.weights().cbegin(), params.weights().cend());
146 return params.support()[d(g)];
Sampling (non) arithmetic values in discrete probability distribution.
Definition DiscreteDistribution.hpp:29
DiscreteDistribution(DiscreteDistribution< State > &&other)=default
Move constructor.
DiscreteDistribution< State > & operator=(DiscreteDistribution< State > const &other)=default
Copy assignment operator.
DiscreteDistribution(const param_type &p)
Constructor.
Definition DiscreteDistribution.hpp:93
DiscreteDistribution(std::vector< result_type > &&support, std::vector< double > &&weights) noexcept
Constructor.
Definition DiscreteDistribution.hpp:114
DiscreteDistribution< State > & operator=(DiscreteDistribution< State > &&other)=default
Move assignment operator.
result_type operator()(Generator &g, const param_type ¶ms) const
Generates random numbers that are distributed according to params The entropy is acquired by calling ...
Definition DiscreteDistribution.hpp:143
DiscreteDistribution()=default
Default constructor.
DiscreteDistribution(std::vector< result_type > const &support, std::vector< double > const &weights)
Constructor.
Definition DiscreteDistribution.hpp:107
DiscreteDistribution(DiscreteDistribution< State > const &other)=default
Copy constructor.
result_type operator()(Generator &g) const
Generates random objects that are distributed according to the associated parameter set....
Definition DiscreteDistribution.hpp:131
Random sampling processes.
Definition utils.hpp:26