35 #include <boost/cstdint.hpp> 38 #include <gsl/gsl_rng.h> 74 rng(int32_t seed_,
bool init_now_ =
true);
77 rng(
const std::string & id_, int32_t seed_,
bool init_now_ =
true);
92 void initialize(
const std::string & id_, int32_t seed_ = 0);
97 void init(
const std::string & id_, int32_t seed_ = 0);
116 const std::string &
get_id()
const;
118 void set_id(
const std::string & id_ =
"");
130 DT_THROW_IF(_tracker_, std::logic_error,
"No tracker is defined !");
131 *_tracker_.get() <<
'#' <<
' ' << tag_ << std::endl;
136 DT_THROW_IF(_tracker_, std::logic_error,
"No tracker is defined !");
137 *_tracker_.get() <<
'#' <<
' ' << tag_ <<
" = " << value_ << std::endl;
141 void dump(std::ostream & = std::clog)
const;
143 unsigned long int get();
151 unsigned long int uniform_int(
unsigned long int n_);
154 std::string
name()
const;
156 unsigned long int min()
const;
158 unsigned long int max()
const;
160 void store(
const std::string & filename_)
const;
162 void load(
const std::string & filename_);
176 double flat(
double a_,
double b_);
178 double gaussian(
double sigma_ = 1.0);
180 double gaussian(
double mu_,
double sigma_);
188 unsigned long int poisson(
double mu_);
190 unsigned long int bernoulli(
double p_ = 0.5);
192 unsigned long int binomial(
double p_,
193 unsigned long int n_);
207 void _init_defaults_();
222 unsigned long int _trunc_norm_;
223 std::unique_ptr<std::ofstream> _tracker_;
224 int _tracker_counter_;
230 #endif // MYGSL_RNG_H bool is_seed_valid() const
datatools::logger::priority get_logging_priority() const
Return the logging priority.
void to_buffer(state_buffer_type &) const
void tracker_tag(const std::string &tag_)
Definition: rng.h:129
void set_logging_priority(datatools::logger::priority)
Set the logging priority.
double uniform_pos()
Shoot a real between 0 (excluded) and 1.
virtual ~rng()
Destructor.
void set_id(const std::string &id_="")
void set_seed(int32_t seed_=0)
const std::string & get_id() const
rng()
Default constructor.
bool is_seed_time() const
static const std::string DEFAULT_RNG_ID
Definition: rng.h:57
unsigned long int min() const
bool is_seed_invalid() const
unsigned long int uniform_int(unsigned long int n_)
unsigned long int max() const
Utility macros for exception handling.
static void print_dict(std::ostream &)
std::string name() const
Return the name/ID of the embedded GSL PRNG.
unsigned long int poisson(double mu_)
std::vector< unsigned char > state_buffer_type
Definition: rng.h:60
unsigned long int binomial(double p_, unsigned long int n_)
void from_stream(std::istream &)
double flat(double a_, double b_)
void tracker_tag(const std::string &tag_, const Type &value_)
Definition: rng.h:135
size_t get_internal_state_size() const
void set_tracker(const std::string &filename_)
double gaussian_tail(double min_, double sigma_=1.0)
double chisquare(double nu_=1.0)
static const std::string DEFAULT_RNG_TYPE
Definition: rng.h:58
void to_stream(std::ostream &) const
#define DT_THROW_IF(Condition, ExceptionType, Message)
Definition: exception.h:76
static void default_setup()
void load(const std::string &filename_)
bool is_initialized() const
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
rng & operator=(const rng &)
void from_buffer(const state_buffer_type &)
double gaussian(double sigma_=1.0)
Utilities for logging information.
void init(const std::string &id_, int32_t seed_=0)
unsigned long int bernoulli(double p_=0.5)
double exponential(double sigma_=1.0)
void dump(std::ostream &=std::clog) const
Raw print.
double uniform()
Shoot a real between 0 and 1.
void store(const std::string &filename_) const
Pseudo random number generator.
Definition: rng.h:53