18 #include "../include/tscope5/randomizer.h"
19 #include "../include/tscope5/randomizer_internal.h"
20 #include "../include/tscope5/system_internal.h"
22 #include <gsl/gsl_rng.h>
23 #include <gsl/gsl_randist.h>
45 ts5_log(TS5_LOGLEVEL_5,
"ts5_random_integer(%lu)\n", max);
47 return gsl_rng_uniform_int(_ts5_data.randomizer, max);
61 ts5_log(TS5_LOGLEVEL_5,
"ts5_random_list(%d,%d,%p)\n", nmax, freq, list);
64 for (i = 0; i < nmax * freq; i++) {
68 gsl_ran_shuffle(_ts5_data.randomizer, list, (
unsigned long)(nmax * freq),
95 ts5_log(TS5_LOGLEVEL_5,
"ts5_random_uniform()\n");
97 return gsl_rng_uniform(_ts5_data.randomizer);
112 ts5_log(TS5_LOGLEVEL_5,
"ts5_random_normal(%f,%f)\n", mu, sigma);
114 return (mu + gsl_ran_gaussian(_ts5_data.randomizer, sigma));
128 ts5_log(TS5_LOGLEVEL_5,
"ts5_random_exponential(%f)\n", mu);
130 return gsl_ran_exponential(_ts5_data.randomizer, mu);
157 ts5_log(TS5_LOGLEVEL_4,
"ts5_seed_randomizer(%lu)\n", seed);
159 gsl_rng_set(_ts5_data.randomizer, seed);
double ts5_random_exponential(double mu)
Draw a double from an exponential distribution.
double ts5_random_normal(double mu, double sigma)
Draw a double from a normal distribution.
void ts5_check_randomizer(char *calling_function)
Do some checks at the start of each randomizer function.
void ts5_random_list(const int nmax, const int freq, int *list)
Draw a list of random values without replacement.
void ts5_log(const unsigned int level, const char *format,...)
Send info to a logging window.
unsigned long int ts5_seed_randomizer(const unsigned long int seed)
Seed the randomizer subsystem.
unsigned long int ts5_random_integer(const unsigned long int max)
Draw an integer from a uniform distribution.
double ts5_random_uniform()
Draw a double from a uniform distribution.