Random.h
Go to the documentation of this file.
1 /**
2  Gen::Random is an IRandom which is implemented with standard C++ <random>.
3  */
4 
5 #ifndef WIRECELLGEN_RANDOM
6 #define WIRECELLGEN_RANDOM
7 
10 
11 namespace WireCell {
12  namespace Gen {
13 
14  class Random : public IRandom, public IConfigurable {
15  public:
16  Random(const std::string& generator = "default",
17  const std::vector<unsigned int> seeds = {0,0,0,0,0});
18  virtual ~Random() {}
19 
20  // IConfigurable interface
21  virtual void configure(const WireCell::Configuration& config);
23 
24  /// Sample a binomial distribution
25  virtual int binomial(int max, double prob);
26 
27  /// Sample a Poisson distribution.
28  virtual int poisson(double mean);
29 
30  /// Sample a normal distribution.
31  virtual double normal(double mean, double sigma);
32 
33  /// Sample a uniform distribution
34  virtual double uniform(double begin, double end);
35 
36  /// Sample an exponential distribution
37  virtual double exponential(double mean);
38 
39  /// Sample a uniform integer range.
40  virtual int range(int first, int last);
41 
42  private:
44  std::vector<unsigned int> m_seeds;
46  };
47 
48  }
49 }
50 #endif
virtual double normal(double mean, double sigma)
Sample a normal distribution.
Definition: Random.cxx:118
std::string string
Definition: nybbler.cc:12
virtual double exponential(double mean)
Sample an exponential distribution.
Definition: Random.cxx:128
virtual int binomial(int max, double prob)
Sample a binomial distribution.
Definition: Random.cxx:109
std::string m_generator
Definition: Random.h:43
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:72
std::vector< unsigned int > m_seeds
Definition: Random.h:44
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
Definition: Random.cxx:97
static Config * config
Definition: config.cpp:1054
virtual ~Random()
Definition: Random.h:18
virtual double uniform(double begin, double end)
Sample a uniform distribution.
Definition: Random.cxx:123
static int max(int a, int b)
generator
Definition: train.py:468
IRandom * m_pimpl
Definition: Random.h:45
virtual int poisson(double mean)
Sample a Poisson distribution.
Definition: Random.cxx:113
Definition: Main.h:22
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:13
virtual void configure(const WireCell::Configuration &config)
Accept a configuration.
Definition: Random.cxx:71
Json::Value Configuration
Definition: Configuration.h:50
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:67
Random(const std::string &generator="default", const std::vector< unsigned int > seeds={0, 0, 0, 0, 0})
Definition: Random.cxx:25
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:15
virtual int range(int first, int last)
Sample a uniform integer range.
Definition: Random.cxx:133