Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
random_algorithm.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "randombit_generator.h"
4 #include <functional>
5 
6 namespace hgps {
8 class Random {
9  public:
10  Random() = delete;
13  Random(RandomBitGenerator &generator);
14 
17  int next_int();
18 
22  int next_int(const int &max_value);
23 
28  int next_int(const int &min_value, const int &max_value);
29 
32  double next_double() noexcept;
33 
36  double next_normal();
37 
42  double next_normal(const double &mean, const double &standard_deviation);
43 
48  int next_empirical_discrete(const std::vector<int> &values, const std::vector<float> &cdf);
49 
54  int next_empirical_discrete(const std::vector<int> &values, const std::vector<double> &cdf);
55 
56  private:
57  std::reference_wrapper<RandomBitGenerator> engine_;
58  int next_int_internal(const int &min_value, const int &max_value);
59  double next_uniform_internal(const double &min_value, const double &max_value);
60  double next_normal_internal(const double &mean, const double &standard_deviation);
61 };
62 } // namespace hgps
Pseudo-random number generator algorithm interface.
Definition: randombit_generator.h:9
General purpose Random number generator algorithms.
Definition: random_algorithm.h:8
Random()=delete
double next_double() noexcept
Generates a random floating point number in range [0,1)
Definition: random_algorithm.cpp:27
double next_normal()
Generates the next random number from a standard normal distribution.
Definition: random_algorithm.cpp:29
int next_int()
Generates the next random integer in the sequence.
Definition: random_algorithm.cpp:11
int next_empirical_discrete(const std::vector< int > &values, const std::vector< float > &cdf)
Samples a random value from an empirical distribution.
Definition: random_algorithm.cpp:42
Top-level namespace for Health-GPS C++ API.
Definition: analysis_definition.h:8
Global namespace.
Definition: jsonparser.h:88