LibRan
0.1
Pseudo-random number distribution generator
|
Piecewise uniform distribution. More...
Go to the source code of this file.
Functions | |
int | LR_pcs_new (LR_obj *o, int n) |
LR_pcs_new(LR_obj *o, int n) - create a new piecewise uniform object set of segments. More... | |
int | LR_pcs_rm (LR_obj *o) |
LR_pcs_rm(LR_obj *o) - strip out the LR_pcs object part of LR_obj. More... | |
int | LR_pcs_set (LR_obj *o, double x, double p) |
LR_pcs_set(LR_obj *o, double x) - add interval boundary (will order internally). More... | |
int | LR_pcs_norm (LR_obj *o) |
LR_pcs_norm(LR_obj *o) - normalize the interval scale factors. More... | |
double | LRd_piece_RAN (LR_obj *o) |
LRd_piece_RAN(LR_obj *o) - double random piecewise uniform distribution random variate. More... | |
double | LRd_piece_PDF (LR_obj *o, double x) |
LRd_piece_PDF(LR_obj *o, double x) - double piecewise uniform probablity distribution function. More... | |
double | LRd_piece_CDF (LR_obj *o, double x) |
LRd_piece_CDF(LR_obj *o, double x) - double piecewise uniform cumulative distribution function. More... | |
float | LRf_piece_RAN (LR_obj *o) |
LRf_piece_RAN(LR_obj *o) - float random piecewise uniform distribution. More... | |
float | LRf_piece_PDF (LR_obj *o, float x) |
LRf_piece_PDF(LR_obj *o, float x) - float piecewise uniform probablity distribution function. More... | |
float | LRf_piece_CDF (LR_obj *o, float x) |
LRf_piece_CDF(LR_obj *o, float x) - float piecewise uniform cumulative distribution function. More... | |
Piecewise uniform distribution.
The Piecewise uniform distribution is a probability distribution function that looks like a histogram, where each block is of some width and height of
.
Once the piecewise distribution object is created the set of blocks can be defined with the LR_pcs_*
() functions. (Note: the LR_aux_*
() functions are equivalent and generic procedures and can be used instead.)
The auxilliary methods found here are also used by the linear spline distribution method.
The probability and cumulative distribution functions as defined by the above code fragment looks like this:
Definition in file LRpiece.c.
int LR_pcs_new | ( | LR_obj * | o, |
int | n | ||
) |
LR_pcs_new(LR_obj *o, int n) - create a new piecewise uniform object set of segments.
This routine must be called after the LR_obj
object is created and it allocates memory for the number of expected segments.
o | LR_obj object |
n | largest number of intervals |
int LR_pcs_norm | ( | LR_obj * | o | ) |
LR_pcs_norm(LR_obj *o) - normalize the interval scale factors.
The LR_pcs_norm()
function is absolutely required to be called so the integrated probability density equals one. If this routine is not called subsequent calls to the CDF/PDF/RAN functions will raise an error (returning a NAN).
o | LR_obj object |
int LR_pcs_rm | ( | LR_obj * | o | ) |
int LR_pcs_set | ( | LR_obj * | o, |
double | x, | ||
double | p | ||
) |
LR_pcs_set(LR_obj *o, double x) - add interval boundary (will order internally).
The LR_pcs_set
function defines the set of segments for the probability density function. It adds a new boundary and the value of the probability density following that boundary.
Boundary values can be defined in any order and will be ordered internally by this method.
The first segment (and boundary) is defined through the LR_set_all()
function, which also defines the last segment end point.
The set of segments and the probability density is relatively defined with LR_pcs_set()
. Once all the segments are defined then the probability density must be normalized with LR_pcs_norm()
such that the total integrated value is equal to one!
o | LR_obj object |
x | interval boundary to add |
p | relative probablity for interval greater than x |
double LRd_piece_CDF | ( | LR_obj * | o, |
double | x | ||
) |
LRd_piece_CDF(LR_obj *o, double x) - double piecewise uniform cumulative distribution function.
o | LR_obj object |
x | value |
double LRd_piece_PDF | ( | LR_obj * | o, |
double | x | ||
) |
LRd_piece_PDF(LR_obj *o, double x) - double piecewise uniform probablity distribution function.
o | LR_obj object |
x | value |
double LRd_piece_RAN | ( | LR_obj * | o | ) |
LRd_piece_RAN(LR_obj *o) - double random piecewise uniform distribution random variate.
o | LR_obj object |
float LRf_piece_CDF | ( | LR_obj * | o, |
float | x | ||
) |
LRf_piece_CDF(LR_obj *o, float x) - float piecewise uniform cumulative distribution function.
o | LR_obj object |
x | value |
float LRf_piece_PDF | ( | LR_obj * | o, |
float | x | ||
) |
LRf_piece_PDF(LR_obj *o, float x) - float piecewise uniform probablity distribution function.
o | LR_obj object |
x | value |
float LRf_piece_RAN | ( | LR_obj * | o | ) |
LRf_piece_RAN(LR_obj *o) - float random piecewise uniform distribution.
o | LR_obj object |