LibRan  0.1
Pseudo-random number distribution generator
Functions
LRdf.c File Reference

Call the associated functions for the given random variate distribution. More...

#include <math.h>
#include "libran.h"
Include dependency graph for LRdf.c:

Go to the source code of this file.

Functions

double LRd_RAN (LR_obj *o)
 LRd_RAN(LR_obj *o) - random variate generator. More...
 
double LRd_PDF (LR_obj *o, double x)
 LRd_PDF(LR_obj *o, double x) - probability distribution function. More...
 
double LRd_CDF (LR_obj *o, double x)
 LRd_CDF(LR_obj *o, double x) - cumulative distribution function. More...
 
float LRf_RAN (LR_obj *o)
 LRf_RAN(LR_obj *o) - random variate generator. More...
 
float LRf_PDF (LR_obj *o, float x)
 LRf_PDF(LR_obj *o, float x) - probability distribution function. More...
 
float LRf_CDF (LR_obj *o, float x)
 LRf_CDF(LR_obj *o, float x) - cumulative distribution function. More...
 
int LRi_RAN (LR_obj *o)
 LRi_RAN(LR_obj *o) - random variate generator. More...
 
float LRi_PDF (LR_obj *o, int x)
 LRi_PDF(LR_obj *o, int x) - probability distribution function. More...
 
float LRi_CDF (LR_obj *o, int x)
 LRi_CDF(LR_obj *o, int x) - cumulative distribution function. More...
 
int LR_aux_new (LR_obj *o, int n)
 LR_aux_new(LR_obj *o, int n) - initialize a new auxiliary object. More...
 
int LR_aux_rm (LR_obj *o)
 LR_aux_rm(LR_obj *o) - remove the auxiliary object. More...
 
int LR_aux_set (LR_obj *o, double x, double p)
 LR_aux_set(LR_obj *o, double x, double p) - add an interval boundary for the underlying distribution. More...
 
int LR_aux_norm (LR_obj *o)
 LR_aux_norm(LR_obj *o) - process given intervals and normalize values. More...
 

Detailed Description

Call the associated functions for the given random variate distribution.

These routines are the generic function calls. They use the the distribution and generation functions defined for the given random variate distribution, so the programmer need not remember the exact function name when making calls to the distribution functions or the random variate generater.

Also using these routines instead of calling the associated specific functions allows one to quickly switch from one random variate distribution to another without making any programmatic changes.

These routines call the associated PDF, CDF, RAN functions given in the LR_obj object as specified by the LR_type and LR_data_type.

There are also generic auxiliary functions: new, rm, set, and norm. The auxiliary methods are not dependent on the LR_data_type, but only on the LR_type and only if they are necessary for the given random variate distribution.

Auxiliary Functions

The current set of auxiliary functions are needed for the piecewise uniform (LR_type -> piece) and the linear spline distributions (LR_type -> lspline). The auxiliary object will be created when the LR_obj is created.

Use these functions instead of the distribution specific versions. These functions are safe to call from any other distribution, but will return an error which can be ignored if the value returned is equal to LRerr_NoAuxiliaryObject.

Definition in file LRdf.c.

Function Documentation

◆ LR_aux_new()

int LR_aux_new ( LR_obj o,
int  n 
)

LR_aux_new(LR_obj *o, int n) - initialize a new auxiliary object.

The generic method for creating a new auxiliary object for those random variate distributions that need it. Can be called otherwise but raises an ignorable error.

Parameters
oLR_obj object
nmaxiumum number of intervals
Returns
0 if successful, else non-zero if failed

Definition at line 241 of file LRdf.c.

◆ LR_aux_norm()

int LR_aux_norm ( LR_obj o)

LR_aux_norm(LR_obj *o) - process given intervals and normalize values.

The generic method for normalizing the given intervals for the auxiliary object for those random variate distributions that need it. Can be called otherwise but raises an ignorable error.

Parameters
oLR_obj object
Returns
0 if successful, else non-zero if failed

Definition at line 301 of file LRdf.c.

◆ LR_aux_rm()

int LR_aux_rm ( LR_obj o)

LR_aux_rm(LR_obj *o) - remove the auxiliary object.

The generic method for removing or deallocating an auxiliary object for those random variate distributions that need it. Can be called otherwise but raises an ignorable error.

Parameters
oLR_obj object
Returns
0 if successful, else non-zero if failed

Definition at line 260 of file LRdf.c.

◆ LR_aux_set()

int LR_aux_set ( LR_obj o,
double  x,
double  p 
)

LR_aux_set(LR_obj *o, double x, double p) - add an interval boundary for the underlying distribution.

The generic method for adding an interval boundary for an auxiliary object for those random variate distributions that need it. Can be called otherwise but raises an ignorable error.

Parameters
oLR_obj object
xinterval boundary to add
prelative probablity for interval greater than x
Returns
0 if successful, else non-zero if failed

Definition at line 282 of file LRdf.c.

◆ LRd_CDF()

double LRd_CDF ( LR_obj o,
double  x 
)

LRd_CDF(LR_obj *o, double x) - cumulative distribution function.

This method will call the specific random variate cumulative distribution function as determined by the object's LR_type and LR_data_type. Note that using the wrong data type will return a NAN and raise an error.

Parameters
oLR_obj object
xvalue
Returns
double CDF at x

Definition at line 101 of file LRdf.c.

◆ LRd_PDF()

double LRd_PDF ( LR_obj o,
double  x 
)

LRd_PDF(LR_obj *o, double x) - probability distribution function.

This method will call the specific random variate probability distribution function as determined by the object's LR_type and LR_data_type. Note that using the wrong data type will return a NAN and raise an error.

Parameters
oLR_obj object
xvalue
Returns
double PDF at x

Definition at line 80 of file LRdf.c.

◆ LRd_RAN()

double LRd_RAN ( LR_obj o)

LRd_RAN(LR_obj *o) - random variate generator.

This method will call the specific random variate generator as determined by the object's LR_type and LR_data_type. Note that using the wrong data type will return a NAN and raise an error.

Parameters
oLR_obj object
Returns
double random variate

Definition at line 59 of file LRdf.c.

◆ LRf_CDF()

float LRf_CDF ( LR_obj o,
float  x 
)

LRf_CDF(LR_obj *o, float x) - cumulative distribution function.

This method will call the specific random variate cumulative distribution function as determined by the object's LR_type and LR_data_type. Note that using the wrong data type will return a NAN and raise an error.

Parameters
oLR_obj object
xvalue
Returns
float CDF at x

Definition at line 161 of file LRdf.c.

◆ LRf_PDF()

float LRf_PDF ( LR_obj o,
float  x 
)

LRf_PDF(LR_obj *o, float x) - probability distribution function.

This method will call the specific random variate probability distribution function as determined by the object's LR_type and LR_data_type. Note that using the wrong data type will return a NAN and raise an error.

Parameters
oLR_obj object
xvalue
Returns
float PDF at x

Definition at line 140 of file LRdf.c.

◆ LRf_RAN()

float LRf_RAN ( LR_obj o)

LRf_RAN(LR_obj *o) - random variate generator.

This method will call the specific random variate generator as determined by the object's LR_type and LR_data_type. Note that using the wrong data type will return a NAN and raise an error.

Parameters
oLR_obj object
Returns
float random variate

Definition at line 119 of file LRdf.c.

◆ LRi_CDF()

float LRi_CDF ( LR_obj o,
int  x 
)

LRi_CDF(LR_obj *o, int x) - cumulative distribution function.

This method will call the specific random variate cumulative distribution function as determined by the object's LR_type and LR_data_type. Note that using the wrong data type will return a NAN and raise an error.

Parameters
oLR_obj object
xvalue
Returns
float CDF at x

Definition at line 221 of file LRdf.c.

◆ LRi_PDF()

float LRi_PDF ( LR_obj o,
int  x 
)

LRi_PDF(LR_obj *o, int x) - probability distribution function.

This method will call the specific random variate probability distribution function as determined by the object's LR_type and LR_data_type. Note that using the wrong data type will return a NAN and raise an error.

Parameters
oLR_obj object
xvalue
Returns
float PDF at x

Definition at line 200 of file LRdf.c.

◆ LRi_RAN()

int LRi_RAN ( LR_obj o)

LRi_RAN(LR_obj *o) - random variate generator.

This method will call the specific random variate generator as determined by the object's LR_type and LR_data_type. Note that using the wrong data type will return a NAN and raise an error.

Parameters
oLR_obj object
Returns
int random variate

Definition at line 179 of file LRdf.c.