LibRan
0.1
Pseudo-random number distribution generator
|
Set of LibRan binning functions. More...
Go to the source code of this file.
Functions | |
LR_bin * | LR_bin_new (int n) |
LR_bin_new(LR_data_type d, int n) - create new binning object. More... | |
int | LR_bin_rm (LR_bin **b) |
LR_bin_rm(LR_bin **b) - remove binning object. More... | |
int | LR_bin_set (LR_bin *b, double x) |
LR_bin_set(LR_bin *b, double x) - add bin boundary. More... | |
int | LR_bin_add (LR_bin *b, double x) |
LR_bin_add(LR_bin *b, double x) - collect value to be binned. More... | |
Set of LibRan binning functions.
This set of LibRan functions will set-up or take-down the LR_bin
object and the bins for counting values into bins based on the bin boundaries. Each of the LR_bin
objects is independent of any other object such as the LR_obj
.
Having such bins are useful for visualizing a random variates distribution. Given the total number of samples is N, then the number of likely samples falling within the bin will be
where the bin interval is and
is the probability distribution function (PDF) and
is the cumulative distribution function (CDF).
The bin object also tallies samples below and above the set of bins. If you define n-1 boundaries then there are n bins. The order the boundaries are set is not important. The method orders the boundaries internally.
The following is some example code fragments for defining the bins, tallying the samples, and viewing the results.
Definition in file LRbin.c.
int LR_bin_add | ( | LR_bin * | b, |
double | x | ||
) |
LR_bin_add(LR_bin *b, double x) - collect value to be binned.
This is the tallying routine, where the value x is compared to the boundary values and the appropriate bin array element tally is incremented.
b | LR_bin object |
x | value to count within the given bin. |
LR_bin* LR_bin_new | ( | int | n | ) |
LR_bin_new(LR_data_type d, int n) - create new binning object.
This routine creates a new LR_bin
object and allocates the necessary memory for the boundaries and tally bins. Must give at least the expected number of bins or the number of boundaries plus one.
t | data type |
n | number of bins |
int LR_bin_rm | ( | LR_bin ** | b | ) |
LR_bin_rm(LR_bin **b) - remove binning object.
Since the LR_bin
object allocates memory this method needs to be called to deallocate the memory to avoid memory leaks.
b | LR_bin object address |
int LR_bin_set | ( | LR_bin * | b, |
double | x | ||
) |
LR_bin_set(LR_bin *b, double x) - add bin boundary.
Include another bin boundary, which will be ordered internally. However, it will not identify or flag repeated boundaries.
b | LR_bin object |
x | bin boundary to add |