Tscope5
randomizer.c File Reference

Go to the source code of this file.

Functions

Random integers

In an experiment most of the time you will need random integers, preferably drawn from a list without replacement:

unsigned long int ts5_random_integer (const unsigned int max)
void ts5_random_list (const int nmax, const int freq, int *list)
Random doubles

Tscope5 also gives acces to random numbers drawn from some common distributions:

double ts5_random_uniform ()
double ts5_random_normal (double mu, double sigma)
double ts5_random_exponential (double mu)
Set the random seed

If you do simulation work it is also possible to set the random seed yourself.

Identical seeds always result in the same randomized list.

unsigned long int ts5_seed_randomizer (const unsigned int seed)

Detailed Description

Definition in file randomizer.c.


Function Documentation

unsigned long int ts5_random_integer ( const unsigned int  max)

Draw an integer from a uniform distribution.

Parameters:
maxNumber of possible values of the random integer.
Returns:
An integer from 0 to n-1.
Examples:
randomizer1.c, randomizer3.c, timer3.c, timer4.c, timer5.c, and timer6.c.

Definition at line 34 of file randomizer.c.

void ts5_random_list ( const int  nmax,
const int  freq,
int *  list 
)

Draw a list of random values without replacement.

Parameters:
nmaxMaximum value (output values will range from 0 to n-1).
freqFrequency of each value.
listAdress of the array where the list is stored.
Examples:
randomizer1.c.

Definition at line 50 of file randomizer.c.

double ts5_random_uniform ( )

Draw a double from a uniform distribution.

Returns:
A double precision floating point value from a uniform distribution.

The range includes 0.0 but excludes 1.0.

Examples:
randomizer2.c.

Definition at line 82 of file randomizer.c.

double ts5_random_normal ( double  mu,
double  sigma 
)

Draw a double from a normal distribution.

Parameters:
muMean of the distribution.
sigmaStandard deviation of the distribution.
Returns:
The random value.
Examples:
randomizer2.c.

Definition at line 99 of file randomizer.c.

double ts5_random_exponential ( double  mu)

Draw a double from an exponential distribution.

Parameters:
muMean of the distribution.
Returns:
The random value.
Examples:
randomizer2.c.

Definition at line 115 of file randomizer.c.

unsigned long int ts5_seed_randomizer ( const unsigned int  seed)

Seed the randomizer subsystem.

Parameters:
seedSeed for the randomizer.

If the generator is seeded with the same value of seed on two different runs, the same stream of random numbers will be generated by successive calls to the routines.

The timer is a good source for random seeds.

Examples:
randomizer3.c.

Definition at line 142 of file randomizer.c.