27 : m_generator(generator)
35 template<
typename URNG>
40 std::seed_seq seed(seeds.begin(), seeds.end());
45 std::binomial_distribution<int> distribution(max, prob);
46 return distribution(m_rng);
49 std::poisson_distribution<int> distribution(mean);
50 return distribution(m_rng);
53 std::normal_distribution<double> distribution(mean, sigma);
54 return distribution(m_rng);
58 std::uniform_real_distribution<double> distribution(begin, end);
59 return distribution(m_rng);
62 std::exponential_distribution<double> distribution(mean);
63 return distribution(m_rng);
65 virtual int range(
int first,
int last) {
66 std::uniform_int_distribution<int> distribution(first, last);
67 return distribution(m_rng);
73 auto jseeds = cfg[
"seeds"];
74 if (not jseeds.isNull()) {
75 std::vector<unsigned int>
seeds;
76 for (
auto jseed : jseeds) {
77 seeds.push_back(jseed.asInt());
81 auto gen =
get(
cfg,
"generator",m_generator);
85 if (gen ==
"default") {
88 else if (gen ==
"twister") {
92 warn(
"Gen::Random::configure: warning: unknown random engine: \"{}\" using default", gen);
100 cfg[
"generator"] = m_generator;
102 for (
auto seed : m_seeds) {
105 cfg[
"seeds"] = jseeds;
109 int Gen::Random::binomial(
int max,
double prob)
111 return m_pimpl->binomial(max, prob);
113 int Gen::Random::poisson(
double mean)
115 return m_pimpl->poisson(mean);
118 double Gen::Random::normal(
double mean,
double sigma)
120 return m_pimpl->normal(mean, sigma);
123 double Gen::Random::uniform(
double begin,
double end)
125 return m_pimpl->uniform(begin, end);
128 double Gen::Random::exponential(
double mean)
130 return m_pimpl->exponential(mean);
133 int Gen::Random::range(
int first,
int last)
135 return m_pimpl->range(first, last);
virtual int binomial(int max, double prob)
RandomT(std::vector< unsigned int > seeds)
virtual double uniform(double begin, double end)
virtual double exponential(double mean)
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
std::vector< pointer > vector
Vector of shared pointers.
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
WIRECELL_FACTORY(Random, WireCell::Gen::Random, WireCell::IRandom, WireCell::IConfigurable) using namespace WireCell
static int max(int a, int b)
std::vector< TrajPoint > seeds
virtual int poisson(double mean)
Json::Value Configuration
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
virtual int range(int first, int last)
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
virtual double normal(double mean, double sigma)