Main Page | Modules | Data Structures | File List | Globals | Related Pages

random.h File Reference


Detailed Description

Generates random numbers in a number of ways, and has support for saving and restoring the state of the random number generator.

Go to the source code of this file.

Functions

void RandomInit (void)
 Should be called before calling other random functions.

int RandomRange (int min, int max)
 Returns a number between the min and max (inclusive).

long RandomLong (void)
 Returns a random long integer.

double RandomDouble (void)
 Returns a random double from 0 - 1.

double RandomGaussian (double mean, double stdev)
 Samples from a Gaussian with the specified parameters.

double RandomStandardNormal (void)
 Samples from the standard normal distribution.

void RandomSeed (unsigned int seed)
 Seeds the random number generator.

void * RandomNewState (unsigned int seed)
 Creates a new random state to use with RandomSetState.

void * RandomSetState (void *state)
 Sets the current random state.

void RandomFreeState (void *state)
 Use this to free any state made with RandomNewState.


Function Documentation

double RandomDouble void   ) 
 

Returns a random double from 0 - 1.

void RandomFreeState void *  state  ) 
 

Use this to free any state made with RandomNewState.

double RandomGaussian double  mean,
double  stdev
 

Samples from a Gaussian with the specified parameters.

void RandomInit void   ) 
 

Should be called before calling other random functions.

long RandomLong void   ) 
 

Returns a random long integer.

void* RandomNewState unsigned int  seed  ) 
 

Creates a new random state to use with RandomSetState.

Each state represents a separate stream of repeatable random numbers. This is implemented with initstate and setstate on Unix and is currently not supported on windows.

int RandomRange int  min,
int  max
 

Returns a number between the min and max (inclusive).

void RandomSeed unsigned int  seed  ) 
 

Seeds the random number generator.

void* RandomSetState void *  state  ) 
 

Sets the current random state.

The state parameter should have been made by RandomNewState. This allows you to have multiple repeatable random number sequences at once. Returns the previous state.

double RandomStandardNormal void   ) 
 

Samples from the standard normal distribution.


Generated for VFML by doxygen hosted by SourceForge.net Logo