1 #ifndef _theplu_yat_random_ 2 #define _theplu_yat_random_ 28 #include "yat/statistics/Histogram.h" 32 #include "yat/utility/boost_exception_ptr.h" 34 #include <boost/concept_check.hpp> 35 #include <boost/iterator/iterator_concepts.hpp> 36 #include <boost/thread.hpp> 37 #include <boost/thread/tss.hpp> 39 #include <gsl/gsl_rng.h> 40 #include <gsl/gsl_randist.h> 43 #ifdef YAT_HAVE_ATOMIC 118 unsigned long max(
void)
const;
124 unsigned long min(
void)
const;
129 std::string
name(
void)
const;
138 const gsl_rng*
rng(
void)
const;
153 void seed(
unsigned long s)
const;
195 RNG& operator=(
const RNG&);
198 void rng_alloc(
void)
const;
200 #ifdef YAT_HAVE_ATOMIC 201 static std::atomic<RNG*> instance_;
203 static RNG* instance_;
207 mutable boost::thread_specific_ptr<gsl_rng> rng_;
208 mutable unsigned long seed_;
210 mutable boost::mutex mutex_;
211 static boost::mutex init_mutex_;
241 const gsl_rng*
rng(
void)
const;
253 void clone(
const gsl_rng&);
297 void seed(
unsigned long s)
const YAT_DEPRECATE;
312 virtual result_type operator()(
void) const = 0;
341 unsigned long operator()(
void)
const;
380 unsigned long operator()(
void)
const;
393 gsl_ran_discrete_t* gen_;
394 std::vector<double> p_;
411 public std::unary_function<unsigned long, unsigned long>
438 unsigned long operator()(
void)
const;
450 unsigned long operator()(
unsigned long n)
const;
453 unsigned long range_;
480 unsigned long operator()(
void)
const;
487 unsigned long operator()(
double p)
const;
521 unsigned long int operator()(
void)
const;
527 unsigned long int operator()(
unsigned int n1,
unsigned int n2,
528 unsigned int t)
const;
565 unsigned long int operator()(
void)
const;
571 unsigned long int operator()(
unsigned int n1,
unsigned int n2,
572 unsigned int t)
const;
603 explicit Poisson(
const double m=1);
608 unsigned long operator()(
void)
const;
616 unsigned long operator()(
const double m)
const;
659 void seed(
unsigned long s)
const YAT_DEPRECATE;
674 virtual result_type operator()(
void) const = 0;
696 double operator()(
void)
const;
720 double operator()(
void)
const;
749 double operator()(
void)
const;
757 double operator()(
const double m)
const;
785 explicit Gaussian(
const double s=1,
const double m=0);
790 double operator()(
void)
const;
798 double operator()(
const double s)
const;
806 double operator()(
const double s,
const double m)
const;
823 template<
typename RandomAccessIterator>
827 std::random_shuffle(first, last, rnd);
General.
Definition: random.h:350
const gsl_rng * rng(void) const
Discrete random number distributions.
Definition: random.h:267
Generates numbers from a histogram in a continuous manner.
Definition: random.h:702
The Department of Theoretical Physics namespace as we define it.
Random Number Generator.
Definition: random.h:91
void seed(unsigned long s) const
Set the seed s for the rng.
unsigned long int result_type
Definition: random.h:275
Class holding state of a random generator.
Definition: random.h:218
Generator of random numbers from an exponential distribution.
Definition: random.h:736
unsigned long seed_from_devurandom(void)
Seed the rng using the /dev/urandom device.
Poisson Distribution.
Definition: random.h:595
Geomtric Distribution.
Definition: random.h:467
void random_shuffle(RandomAccessIterator first, RandomAccessIterator last)
Convenience function to shuffle a range with singleton RNG.
Definition: random.h:824
std::string name(void) const
Returns the name of the random number generator.
Histograms provide a convenient way of presenting the distribution of a set of data.
Definition: Histogram.h:53
unsigned long max(void) const
Returns the largest number that the random number generator can return.
int set_state(const RNG_state &)
Set the state to state.
Continuous random number distributions.
Definition: random.h:629
unsigned long min(void) const
Returns the smallest number that the random number generator can return.
Binomial distribution.
Definition: random.h:326
static RNG * instance(void)
Get an instance of the Random Number Generator.
double result_type
Definition: random.h:637
Gaussian distribution.
Definition: random.h:776