1#ifndef BITSIM_MATHS_STATISTICS_DISTRIBUTIONS_NORMAL_DIST_H
2#define BITSIM_MATHS_STATISTICS_DISTRIBUTIONS_NORMAL_DIST_H
26 static_assert(std::is_floating_point<RealType>::value,
"Not a floating point type");
84 mutable std::normal_distribution<RealType> dist_;
87template <
typename RealType>
97 std::random_device rd{};
98 std::mt19937 gen{rd()};
105 std::mt19937 gen{seed};
109template <
typename RealType>
113 std::vector<RealType> samples(size);
114 std::random_device rd{};
115 std::mt19937 gen{rd()};
117 for (
uint_t i = 0; i < size; ++i)
119 samples[i] = dist_(gen);
125template <
typename RealType>
129 std::vector<RealType> samples(size);
130 std::mt19937 gen(seed);
132 for (
uint_t i = 0; i < size; ++i)
134 samples[i] = dist_(gen);
143 auto mu = dist_.mean();
144 auto std = dist_.stddev();
146 auto factor = 1.0 / (
std * std::sqrt(2.0 * pi));
147 auto exp = std::exp(-0.5 * std::pow((x - mu) /
std, 2.0));
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
result_type std() const
The STD of the distribution.
Definition normal_dist.h:76
result_type pdf(result_type x) const
compute the value of the PDF at the given point
Definition normal_dist.h:140
std::vector< result_type > sample_many(uint_t size) const
sample from the distribution
Definition normal_dist.h:110
result_type mean() const
The mean value of the distribution.
Definition normal_dist.h:71
RealType result_type
The return type every time we call pdf, sample.
Definition normal_dist.h:31
NormalDist()
Constructor.
Definition normal_dist.h:92
result_type sample() const
Sample from the distribution.
Definition normal_dist.h:94
const real_t PI
The PI constant.
Definition bitsim_consts.h:63
Definition bernoulli_dist.cpp:6
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40