random

random —

Synopsis




void        gretl_rand_set_seed             (unsigned int seed);
double      gretl_one_snormal               (void);
void        gretl_uniform_dist              (double *a,
                                             int t1,
                                             int t2);
int         gretl_uniform_dist_minmax       (double *a,
                                             int t1,
                                             int t2,
                                             double min,
                                             double max);
void        gretl_normal_dist               (double *a,
                                             int t1,
                                             int t2);
int         gretl_normal_dist_with_params   (double *a,
                                             int t1,
                                             int t2,
                                             double mean,
                                             double sd);
int         gretl_chisq_dist                (double *a,
                                             int t1,
                                             int t2,
                                             int v);
int         gretl_t_dist                    (double *a,
                                             int t1,
                                             int t2,
                                             int v);
int         gretl_binomial_dist             (double *a,
                                             int t1,
                                             int t2,
                                             int n,
                                             double p);
void        gretl_poisson_dist              (double *a,
                                             int t1,
                                             int t2,
                                             double *m,
                                             int vec);
unsigned int gretl_rand_int_max             (unsigned int max);
unsigned int gretl_rand_int                 (void);
void        gretl_rand_init                 (void);
void        gretl_rand_free                 (void);
unsigned int get_gretl_random_seed          (void);

Description

Details

gretl_rand_set_seed ()

void        gretl_rand_set_seed             (unsigned int seed);

Set a specific (and hence reproducible) seed for gretl's PRNG. But if the value 0 is given for seed, set the seed using the system time (which is the default when libgretl is initialized).

seed : the chosen seed value.

gretl_one_snormal ()

double      gretl_one_snormal               (void);

Returns :

gretl_uniform_dist ()

void        gretl_uniform_dist              (double *a,
                                             int t1,
                                             int t2);

Fill the selected range of array a with pseudo-random drawings from the uniform distribution on 0-1, using the Mersenne Twister.

a : target array
t1 : start of the fill range
t2 : end of the fill range

gretl_uniform_dist_minmax ()

int         gretl_uniform_dist_minmax       (double *a,
                                             int t1,
                                             int t2,
                                             double min,
                                             double max);

Fill the selected subset of array a with pseudo-random drawings from the uniform distribution on min to max, using the Mersenne Twister.

a : target array.
t1 : start of the fill range.
t2 : end of the fill range.
min : lower bound of range.
max :
Returns : 0 on success, 1 on invalid input.

gretl_normal_dist ()

void        gretl_normal_dist               (double *a,
                                             int t1,
                                             int t2);

Fill the selected range of array a with pseudo-random drawings from the standard normal distribution, using the Mersenne Twister for uniform input and the Box-Muller method for converting to the normal distribution.

a : target array
t1 : start of the fill range
t2 : end of the fill range

gretl_normal_dist_with_params ()

int         gretl_normal_dist_with_params   (double *a,
                                             int t1,
                                             int t2,
                                             double mean,
                                             double sd);

Fill the selected range of array a with pseudo-random drawings from the normal distribution with the given mean and standard deviation, using the Mersenne Twister for uniform input and the Box-Muller method for converting to the normal distribution.

a : target array
t1 : start of the fill range
t2 : end of the fill range
mean : mean of the distribution
sd : standard deviation
Returns : 0 on success, 1 on invalid input.

gretl_chisq_dist ()

int         gretl_chisq_dist                (double *a,
                                             int t1,
                                             int t2,
                                             int v);

Fill the selected range of array a with pseudo-random drawings from the Chi-Squared distribution with v degrees of freedom, using the Mersenne Twister for uniform input and the Box-Muller method for converting to the normal distribution.

a : target array.
t1 : start of the fill range.
t2 : end of the fill range.
v : degrees of freedom.
Returns : 0 on success, non-zero on error.

gretl_t_dist ()

int         gretl_t_dist                    (double *a,
                                             int t1,
                                             int t2,
                                             int v);

Fill the selected range of array a with pseudo-random drawings from the Student t distribution with v degrees of freedom, using the Mersenne Twister for uniform input and the Box-Muller method for converting to the normal distribution.

a : target array.
t1 : start of the fill range.
t2 : end of the fill range.
v : degrees of freedom.
Returns : 0 on success, non-zero on error.

gretl_binomial_dist ()

int         gretl_binomial_dist             (double *a,
                                             int t1,
                                             int t2,
                                             int n,
                                             double p);

Fill the selected range of array a with pseudo-random drawings from the binomial distribution with parameters n and p.

a : target array.
t1 : start of the fill range.
t2 : end of the fill range.
n : number of trials.
p : success probability per trial.
Returns : 0 on success, non-zero on error.

gretl_poisson_dist ()

void        gretl_poisson_dist              (double *a,
                                             int t1,
                                             int t2,
                                             double *m,
                                             int vec);

Fill the selected range of array a with pseudo-random drawings from the Poisson distribution with a mean determined by m, which can either be a pointer to a scalar, or an array of length greater than or equal to t2 + 1.

a : target array.
t1 : start of the fill range.
t2 : end of the fill range.
m : mean (see below).
vec : should be 1 if m is an array, else 0.

gretl_rand_int_max ()

unsigned int gretl_rand_int_max             (unsigned int max);

max : the maximum value (open)
Returns : a pseudo-random unsigned int in the interval [0, max) using the Mersenne Twister.

gretl_rand_int ()

unsigned int gretl_rand_int                 (void);

Returns : a pseudo-random unsigned int on the interval [0,0xffffffff] using the Mersenne Twister.

gretl_rand_init ()

void        gretl_rand_init                 (void);

Initialize gretl's PRNG, using the system time as seed.


gretl_rand_free ()

void        gretl_rand_free                 (void);

Free the gretl_rand structure (may be called at program exit).


get_gretl_random_seed ()

unsigned int get_gretl_random_seed          (void);

Returns :