random.h File Reference

Detailed Description

Definition of basic randomization functions.

See Also
random.c.

Definition in file random.h.

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
seedThe 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.

Referenced by AtlasRRTSample(), BuildAtlasFromPoint(), GenerateProjectionPlanes(), randomInBall(), randomInInterval(), randomMax(), randomNormal(), randomWithDistribution(), RRTSample(), SimplexAddNewConstraint(), and TransitionTestRRT().

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
tThe 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().

Referenced by CuikNewtonInBox(), IncrementalSampleCuikSystemInBox(), RandomPointInBox(), RandomPointInPolytope(), and SampleCuikSystemInBox().

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
mThe upper limit for the random generator.
Returns
The randomly selected integer in [0,m].

Definition at line 77 of file random.c.

References randomDouble().

Referenced by ComputeSplitDimInt(), IncrementalSampleCuikSystemInBox(), PolytopeBoundaryPointFromExternalCorner(), RandomPointInAtlas(), RandomPointInAtlasTree(), RandomSmooth(), and SmoothPathInAtlasRRT().

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

Gets a random number following an arbitrary random discrete distribution.

Parameters
mThe size of the distribution (number of options).
sSum of the values in d. If zero the sum is computed inside this function.
dThe 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
rRadius of the ball.
kDimension of the space where the ball is defiend.
pSpace 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
rRadius of the ball.
kDimension of the space where the ball is defiend.
pSpace 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().