random.c File Reference

## Detailed Description

Implementation of the basic randomization functions.

random.h.

Definition in file random.c.

## Functions

void randomReset ()
Resets the random seed. More...

void randomSet (unsigned int seed)
Sets the random seed. More...

double randomDouble ()
Returns a random double in the [0,1] interval. More...

double randomNormal ()
Returns a random double acording to a normal distribution. More...

double randomInInterval (Tinterval *t)
Returns a random double in the given interval. More...

unsigned int randomMax (unsigned int m)
Returns a random integer in the range [0,m]. More...

unsigned int randomWithDistribution (unsigned int m, double s, double *d)
Random number with a given discrete distribution. More...

void randomOnBall (double r, unsigned int k, double *p)
Random number on a k dimensional ball. More...

void randomInBall (double r, unsigned int k, double *p)
Random number in a k dimensional ball. More...

## Function Documentation

 void randomReset ( )

Resets the random seed using the current time so, in principle, the reset is hard to predict.

Definition at line 18 of file random.c.

Referenced by main().

 void randomSet ( unsigned int seed )

Sets the random to the given value. This is used to get repetitive sequences of random numbers in order to debug mainly.

Parameters
 seed The new random seed.

Definition at line 25 of file random.c.

Referenced by main().

 double randomDouble ( )

Returns a random number in the [0,1] interval selected with a uniform distribution.

Returns
A random double in [0,1].

Definition at line 33 of file random.c.

 double randomNormal ( )

Returns a random number following a normal distribution with mean 0 and standard deviation 1.

Returns
A random double.

Definition at line 38 of file random.c.

References FALSE, randomDouble(), and TRUE.

Referenced by randomInBall(), and randomOnBall().

 double randomInInterval ( Tinterval * t )

Returns a random number in the given interval selected with a uniform distribution.

Parameters
 t The interval where to drawn the random sample.
Returns
A random double in the given interval.

Definition at line 67 of file random.c.

References LowerLimit(), randomDouble(), and UpperLimit().

 unsigned int randomMax ( unsigned int m )

Returns a random integer in the range [0,m] selected with a uniform distribution. Observe that m is included as a possible outcome.

Parameters
 m The upper limit for the random generator.
Returns
The randomly selected integer in [0,m].

Definition at line 77 of file random.c.

References randomDouble().

 unsigned int randomWithDistribution ( unsigned int m, double s, double * d )

Gets a random number following an arbitrary random discrete distribution.

Parameters
 m The size of the distribution (number of options). s Sum of the values in d. If zero the sum is computed inside this function. d The value for each option. The values in d are assume possitive but not normalized.

Definition at line 86 of file random.c.

References randomDouble().

Referenced by RandomPointInAtlas(), and RandomPointInAtlasTree().

 void randomOnBall ( double r, unsigned int k, double * p )

Selects a random point on the surface of a k dimensional ball with uniform distribution.

Parameters
 r Radius of the ball. k Dimension of the space where the ball is defiend. p Space for the output point. Must be allocated externally.

Definition at line 110 of file random.c.

References randomNormal().

Referenced by PolytopeRandomPointOnBoundary(), and SPolytopeRandomPointOnBoundary().

 void randomInBall ( double r, unsigned int k, double * p )

Selects a random point inside a k dimensional ball with uniform distribution.

Parameters
 r Radius of the ball. k Dimension of the space where the ball is defiend. p Space for the output point. Must be allocated externally.

Definition at line 126 of file random.c.

References randomDouble(), and randomNormal().

Referenced by RandomPointInSPolytope(), and SPolytopeVolume().