| Libgretl Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
void gretl_rand_set_seed (unsigned int seed); double gretl_one_snormal (void); void gretl_rand_uniform (double *a, int t1, int t2); int gretl_rand_uniform_minmax (double *a, int t1, int t2, double min, double max); int gretl_rand_int_minmax (int *a, int n, int min, int max); void gretl_rand_normal (double *a, int t1, int t2); int gretl_rand_normal_full (double *a, int t1, int t2, double mean, double sd); int gretl_rand_chisq (double *a, int t1, int t2, int v); int gretl_rand_student (double *a, int t1, int t2, int v); int gretl_rand_F (double *a, int t1, int t2, int v1, int v2); int gretl_rand_binomial (double *a, int t1, int t2, int n, double p); void gretl_rand_poisson (double *a, int t1, int t2, const double *m, int vec); int gretl_rand_weibull (double *a, int t1, int t2, double shape, double scale); int gretl_rand_gamma (double *a, int t1, int t2, double shape, double scale); 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 gretl_rand_get_seed (void);
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. |
double gretl_one_snormal (void);
| Returns : | a single drawing from the standard normal distribution. |
void gretl_rand_uniform (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 |
int gretl_rand_uniform_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 : |
upper bound of range. |
| Returns : | 0 on success, 1 on invalid input. |
int gretl_rand_int_minmax (int *a,
int n,
int min,
int max);
Fill array a of length n with pseudo-random drawings
from the uniform distribution on min to max, using the
Mersenne Twister.
a : |
target array. |
n : |
length of array. |
min : |
lower closed bound of range. |
max : |
upper closed bound of range. |
| Returns : | 0 on success, 1 on invalid input. |
void gretl_rand_normal (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 |
int gretl_rand_normal_full (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. |
int gretl_rand_chisq (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 gamma r.v. generator.
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. |
int gretl_rand_student (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. |
int gretl_rand_F (double *a,
int t1,
int t2,
int v1,
int v2);
Fill the selected range of array a with pseudo-random drawings
from the F distribution with v1 and v2 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. |
v1 : |
numerator degrees of freedom. |
v2 : |
denominator degrees of freedom. |
| Returns : | 0 on success, non-zero on error. |
int gretl_rand_binomial (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. |
void gretl_rand_poisson (double *a,
int t1,
int t2,
const 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.
|
int gretl_rand_weibull (double *a,
int t1,
int t2,
double shape,
double scale);
Fill the selected range of array a with pseudo-random drawings
from the Weibull distribution with shape k and scale lambda.
a : |
target array. |
t1 : |
start of the fill range. |
t2 : |
end of the fill range. |
shape : |
shape parameter > 0. |
scale : |
scale parameter > 0. |
| Returns : | 0 on success, non-zero if either parameter is out of bounds. |
int gretl_rand_gamma (double *a,
int t1,
int t2,
double shape,
double scale);
Fill the selected range of array a with pseudo-random drawings
from the specified gamma distribution.
a : |
target array. |
t1 : |
start of the fill range. |
t2 : |
end of the fill range. |
shape : |
shape parameter. |
scale : |
scale parameter. |
| Returns : | 0 on success, non-zero on error. |
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.
|
unsigned int gretl_rand_int (void);
| Returns : | a pseudo-random unsigned int on the interval [0,0xffffffff] using the Mersenne Twister. |
void gretl_rand_init (void);
Initialize gretl's PRNG, using the system time as seed.
void gretl_rand_free (void);
Free the gretl_rand structure (may be called at program exit).