1#ifndef BITSIM_MATHS_STATISTICS_DISTRIBUTIONS_UNIFORM_DISTRIBUTION_H
2#define BITSIM_MATHS_STATISTICS_DISTRIBUTIONS_UNIFORM_DISTRIBUTION_H
6#include <initializer_list>
20template <
typename t>
struct uniform_distribution_selector;
22template <>
struct uniform_distribution_selector<
uint_t>
24 using distribution_type = std::uniform_int_distribution<uint_t>;
27template <>
struct uniform_distribution_selector<
int_t>
29 using distribution_type = std::uniform_int_distribution<int_t>;
32template <>
struct uniform_distribution_selector<
lint_t>
34 using distribution_type = std::uniform_int_distribution<lint_t>;
37template <>
struct uniform_distribution_selector<
real_t>
39 using distribution_type = std::uniform_real_distribution<real_t>;
42template <>
struct uniform_distribution_selector<
float_t>
44 using distribution_type = std::uniform_real_distribution<float_t>;
86 uniform_distribution_selector<out_type>::distribution_type distribution_;
89template <
typename OutType>
92 : range_(a, b), distribution_(a, b)
96template <
typename OutType>
98 : UniformDist<OutType>(range.first, range.second)
106 std::random_device rd;
109 std::mt19937 gen(rd());
111 return distribution_(gen);
114template <
typename OutType>
118 std::mt19937 gen(seed);
119 return distribution_(gen);
153 std::vector<real_t>
probabilities()
const {
return distribution_.probabilities(); }
157 std::discrete_distribution<out_type> distribution_;
160template <
typename OutType,
typename WeightType>
161template <
typename VectorType>
163 : weights_(weights), distribution_(weights.begin(), weights.end())
167template <
typename OutType,
typename WeightType>
169 std::initializer_list<WeightType> weights)
170 : weights_(weights), distribution_(weights)
174template <
typename OutType,
typename WeightType>
180 std::random_device rd;
183 std::mt19937 gen(rd());
184 return distribution_(gen);
187template <
typename OutType,
typename WeightType>
192 std::mt19937 gen(seed);
193 return distribution_(gen);
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
Definition bernoulli_dist.cpp:6
Definition math_utils.h:14
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
float float_t
float
Definition bitsim_types.h:25
double real_t
real_t
Definition bitsim_types.h:20
int int_t
integer type
Definition bitsim_types.h:30
long int lint_t
long int type
Definition bitsim_types.h:35