LAL  7.5.0.1-8083555

Detailed Description

Functions for generating random numbers.

Description

The routines LALCreateRandomParams() and LALDestroyRandomParams() create and destroy a parameter structure for the generation of random variables. The creation routine requires a random number seed seed. If the seed is zero then a seed is generated using the current time.

The routine LALUniformDeviate() returns a single random deviate distributed uniformly between zero and unity.

The routine LALNormalDeviates() fills a vector with normal (Gaussian) deviates with zero mean and unit variance, whereas the functionXLALNormalDeviate just returns one normal distributed random number.

Operating Instructions

static RandomParams *params;
static REAL4Vector *vector;
INT4 seed = 0;
LALCreateVector( &status, &vector, 9999 );
LALCreateRandomParams( &status, &params, seed );
/\* fill vector with uniform deviates *\/
for ( i = 0; i < vector->length; ++i )
{
LALUniformDeviate( &status, vector->data + i, params );
}
/\* fill vector with normal deviates *\/
LALNormalDeviates( &status, vector, params );
LALDestroyVector( &status, &vector );
uint32_t UINT4
Four-byte unsigned integer.
int32_t INT4
Four-byte signed integer.
void LALCreateRandomParams(LALStatus *status, RandomParams **params, INT4 seed)
Definition: Random.c:266
void LALNormalDeviates(LALStatus *status, REAL4Vector *deviates, RandomParams *params)
Definition: Random.c:333
void LALUniformDeviate(LALStatus *status, REAL4 *deviate, RandomParams *params)
Definition: Random.c:309
void LALDestroyRandomParams(LALStatus *status, RandomParams **params)
Definition: Random.c:290
void LALDestroyVector(LALStatus *, REAL4Vector **)
void LALCreateVector(LALStatus *, REAL4Vector **, UINT4)
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
Vector of type REAL4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:145
REAL4 * data
Pointer to the data array.
Definition: LALDatatypes.h:150
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:149
This structure contains the parameters necessary for generating the current sequence of random number...
Definition: Random.h:86

Algorithm

This is an implementation of the random number generators ran1 and gasdev described in Numerical Recipes [22] .

Prototypes

INT4 XLALBasicRandom (INT4 i)
 
RandomParamsXLALCreateRandomParams (INT4 seed)
 
void XLALResetRandomParams (RandomParams *params, INT4 seed)
 
void XLALDestroyRandomParams (RandomParams *params)
 
REAL4 XLALUniformDeviate (RandomParams *params)
 
int XLALNormalDeviates (REAL4Vector *deviates, RandomParams *params)
 
REAL4 XLALNormalDeviate (RandomParams *params)
 
void LALCreateRandomParams (LALStatus *status, RandomParams **params, INT4 seed)
 
void LALDestroyRandomParams (LALStatus *status, RandomParams **params)
 
void LALUniformDeviate (LALStatus *status, REAL4 *deviate, RandomParams *params)
 
void LALNormalDeviates (LALStatus *status, REAL4Vector *deviates, RandomParams *params)
 

Variables

static const INT4 a = 16807
 
static const INT4 m = 2147483647
 
static const INT4 q = 127773
 
static const INT4 r = 2836
 
static const REAL4 eps = 1.2e-7
 

Function Documentation

◆ XLALBasicRandom()

INT4 XLALBasicRandom ( INT4  i)

Definition at line 92 of file Random.c.

◆ XLALCreateRandomParams()

RandomParams* XLALCreateRandomParams ( INT4  seed)

Definition at line 102 of file Random.c.

◆ XLALResetRandomParams()

void XLALResetRandomParams ( RandomParams params,
INT4  seed 
)

Definition at line 122 of file Random.c.

◆ XLALDestroyRandomParams()

void XLALDestroyRandomParams ( RandomParams params)

Definition at line 140 of file Random.c.

◆ XLALUniformDeviate()

REAL4 XLALUniformDeviate ( RandomParams params)

Definition at line 146 of file Random.c.

◆ XLALNormalDeviates()

int XLALNormalDeviates ( REAL4Vector deviates,
RandomParams params 
)

Definition at line 171 of file Random.c.

◆ XLALNormalDeviate()

REAL4 XLALNormalDeviate ( RandomParams params)

Definition at line 234 of file Random.c.

◆ LALCreateRandomParams()

void LALCreateRandomParams ( LALStatus status,
RandomParams **  params,
INT4  seed 
)

Definition at line 266 of file Random.c.

◆ LALDestroyRandomParams()

void LALDestroyRandomParams ( LALStatus status,
RandomParams **  params 
)

Definition at line 290 of file Random.c.

◆ LALUniformDeviate()

void LALUniformDeviate ( LALStatus status,
REAL4 deviate,
RandomParams params 
)

Definition at line 309 of file Random.c.

◆ LALNormalDeviates()

void LALNormalDeviates ( LALStatus status,
REAL4Vector deviates,
RandomParams params 
)

Definition at line 333 of file Random.c.

Variable Documentation

◆ a

const INT4 a = 16807
static

Definition at line 79 of file Random.c.

◆ m

const INT4 m = 2147483647
static

Definition at line 80 of file Random.c.

◆ q

const INT4 q = 127773
static

Definition at line 81 of file Random.c.

◆ r

const INT4 r = 2836
static

Definition at line 82 of file Random.c.

◆ eps

const REAL4 eps = 1.2e-7
static

Definition at line 84 of file Random.c.