15namespace utils::maths::stats
27 static_assert(std::is_floating_point<RealType>::value,
"Not a floating point type");
85 mutable std::normal_distribution<RealType> dist_;
88template <
typename RealType>
98 std::random_device
rd{};
99 std::mt19937
gen{
rd()};
106 std::mt19937
gen{seed};
110template <
typename RealType>
114 std::vector<RealType>
samples(size);
115 std::random_device
rd{};
116 std::mt19937
gen{
rd()};
126template <
typename RealType>
130 std::vector<RealType>
samples(size);
131 std::mt19937
gen(seed);
144 auto mu = dist_.mean();
145 auto std = dist_.stddev();
147 auto factor = 1.0 / (std * std::sqrt(2.0 *
pi));
148 auto exp = std::exp(-0.5 * std::pow((x -
mu) / std, 2.0));
Wrapper to std::normal_distribution to facilitate sampling multiple values, sampling with a given see...
Definition normal_dist.h:24
result_type mean() const
The mean value of the distribution.
Definition normal_dist.h:72
result_type std() const
The STD of the distribution.
Definition normal_dist.h:77
std::vector< result_type > sample_many(uint_t size) const
sample from the distribution
Definition normal_dist.h:111
NormalDist()
Constructor.
Definition normal_dist.h:93
result_type pdf(result_type x) const
compute the value of the PDF at the given point
Definition normal_dist.h:141
RealType result_type
Definition normal_dist.h:32
result_type sample() const
Sample from the distribution.
Definition normal_dist.h:95
const real_t PI
The PI constant.
Definition bitrl_consts.h:49
OutT resolve(const std::string &name, const std::map< std::string, std::any > &input)
Definition std_map_utils.h:25
Definition bitrl_consts.h:14
std::size_t uint_t
uint_t
Definition bitrl_types.h:43