Subsections

Randomization

Defined in random.h and random.c

This part contains a number of randomization functions based upon an paper by Marc Brysbaert in BRMIC, 1992. More specifically:

When working with complex randomization, it's better to use two programs: one to produce the randomized list and one to run the trials, based on the values in the randomized list. These are two completely different jobs and putting these together can complicate the testing of your program.

Another option is to use the statistical language R to produce random lists because it offers more sophisticated randomizers.

int ts_rseed (int newseed[3]);

Provides the possibility of user initiated random seeds. To be used for simulations: identical seeds always result in the same randomized list.

int ts_rseedfile (char *file);

Takes the seeds from a file. The last used seeds is always written to seed.dat. Starting a new random sequence with the seeds in this file can be used to reduce the chance of overlapping random series in sequential runs to zero. However, chances of overlapping series is by standard incredibly small so this function is to please the die-hard control freaks. There is even a risk in using this function: if you copy your program to different computers, without deleting seed.dat, all your computers will generate the same random lists.

double ts_runif ();

Returns a random double, drawn from a uniform distribution with minimum 0 and maximum 1. This is the basic random function used by all other functions below. The seeds are automatically initialized at the first call of the function. This initialization is based upon the clock unless the seeds are provided by the user by ts_rseed or ts_seedfile.

double ts_rexp ();

Returns a random double drawn from a distribution with exponential decreasing density. Minimum is 0 and mean is 1.

double ts_rnorm (double mean, double sd);

Returns a random double drawn from a normal distribution with mean mean and standard deviation sd (for a standard normal distribution use mean 0 and standard deviation 1).

int ts_rint (int nmax);

Returns a random integer from the specified range [0:nmax-1].

int ts_rlist (int nmax, int freq, int *list);

Fills *list with a list of random integers. This list contains all numbers from 0 to nmax-1 freq times.

Don't forget to provide an array large enough to contain the entire list (size = nmax x freq).

int ts_rslist (int nmax, int freq, int *list);

Fills *list with a list of random integers. This list contains all coupled combinations of the numbers 0 to nmax-1 freq times.

Don't forget to provide an array large enough to contain the entire list (size = (nmax x nmax x freq)+1).


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information