LAL  7.1.7.1-9b0afb2

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 );
LALDestroyRandomParams( &status, &params );
LALDestroyVector( &status, &vector );

Algorithm

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

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.