1 #ifndef SLAM_CTOR_CORE_RANDOM_UTILS_H 2 #define SLAM_CTOR_CORE_RANDOM_UTILS_H 11 virtual double sample(T& rnd_engine) = 0;
12 virtual std::unique_ptr<RandomVariable1D<T>>
clone()
const = 0;
16 template <
typename Engine>
20 : _mean{mean}, _stddev{stddev}, _distr{_mean, _stddev} {}
22 double sample(Engine &rnd_engine)
override {
23 return _distr(rnd_engine);
26 std::unique_ptr<RandomVariable1D<Engine>>
clone()
const override {
27 return std::make_unique<GaussianRV1D<Engine>>(_mean, _stddev);
36 template <
typename Engine>
40 : _from{from}, _to{to}, _distr{_from, _to} {}
42 double sample(Engine &rnd_engine)
override {
43 return _distr(rnd_engine);
46 std::unique_ptr<RandomVariable1D<Engine>>
clone()
const override {
47 return std::make_unique<UniformRV1D<Engine>>(_from, _to);
53 std::uniform_real_distribution<>
_distr;
std::unique_ptr< RandomVariable1D< Engine > > clone() const override
GaussianRV1D(double mean, double stddev)
virtual std::unique_ptr< RandomVariable1D< T > > clone() const =0
std::normal_distribution _distr
virtual double sample(T &rnd_engine)=0
virtual ~RandomVariable1D()
double sample(Engine &rnd_engine) override