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

The Erlang distribution with shape k > 0 and scale m > 0. More...

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

Go to the source code of this file.

Functions

double LRd_erlang_RAN (LR_obj *o)
 LRd_erlang_RAN(LR_obj *o) - double random negative exponential distribution using the inversion method. Default values: scale m = 1. More...
 
double LRd_erlang_PDF (LR_obj *o, double x)
 LRd_erlang_PDF(LR_obj *o, double x) - Erlang distribution probablity distribution function. More...
 
double LRd_erlang_CDF (LR_obj *o, double x)
 LRd_erlang_CDF(LR_obj *o, double x) - Erlang distribution cumulative distribution function. More...
 
float LRf_erlang_RAN (LR_obj *o)
 LRf_erlang_RAN(LR_obj *o) - float random negative exponential distribution using the inversion method. Default values: scale m = 1. More...
 
float LRf_erlang_PDF (LR_obj *o, float x)
 LRf_erlang_PDF(LR_obj *o, float x) - Erlang distribution probablity distribution function. More...
 
float LRf_erlang_CDF (LR_obj *o, float x)
 LRf_erlang_CDF(LR_obj *o, float x) - Erlang distribution cumulative distribution function. More...
 

Detailed Description

The Erlang distribution with shape k > 0 and scale m > 0.

The pseudo-random numbers are distributed from the Erlang distribution. It's only defined on interval $ x \ge 0 $ and zero otherwise. This distribution typically represents the waiting time between k occurrences of the events. The number of events in a given amount time is described by the Poisson distribution. The attributes k is an integer greater than zero, and the scale m is greater than zero.

\begin{eqnarray*} \mbox{PDF}(x) &= \left\{ \begin{array}{ll} 0, & x < 0 \\ \frac{x^{k-1} e^{-\frac{x}{m}}}{m^k (k-1)!}, & 0 \le x . \end{array} \right. \\ \\ \mbox{CDF}(x) &= \left\{ \begin{array}{ll} 0, & x < 0 \\ 1 - e^{-\frac{x}{m}}\sum_{n=0}^{k-1} \frac{(\frac{x}{m})^n}{n!} , & 0 \le x . \end{array} \right. \end{eqnarray*}

The default is $ m = 1 $ and s will be set to $ 1/m $ for calculation efficiency. Do not set s when declaring this distribution. The default for k = 1 , which is also the nexp distribution.

See also
LRnexp.c
ErlangDistribution.png

Definition in file LRerlang.c.

Function Documentation

◆ LRd_erlang_CDF()

double LRd_erlang_CDF ( LR_obj o,
double  x 
)

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

Parameters
oLR_obj object
xvalue
Returns
double CDF at x

Definition at line 118 of file LRerlang.c.

◆ LRd_erlang_PDF()

double LRd_erlang_PDF ( LR_obj o,
double  x 
)

LRd_erlang_PDF(LR_obj *o, double x) - Erlang distribution probablity distribution function.

Parameters
oLR_obj object
xvalue
Returns
double PDF at x

Definition at line 87 of file LRerlang.c.

◆ LRd_erlang_RAN()

double LRd_erlang_RAN ( LR_obj o)

LRd_erlang_RAN(LR_obj *o) - double random negative exponential distribution using the inversion method. Default values: scale m = 1.

Parameters
oLR_obj object
Returns
double

Definition at line 66 of file LRerlang.c.

◆ LRf_erlang_CDF()

float LRf_erlang_CDF ( LR_obj o,
float  x 
)

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

Parameters
oLR_obj object
xvalue
Returns
float CDF at x

Definition at line 194 of file LRerlang.c.

◆ LRf_erlang_PDF()

float LRf_erlang_PDF ( LR_obj o,
float  x 
)

LRf_erlang_PDF(LR_obj *o, float x) - Erlang distribution probablity distribution function.

Parameters
oLR_obj object
xvalue
Returns
float PDF at x

Definition at line 163 of file LRerlang.c.

◆ LRf_erlang_RAN()

float LRf_erlang_RAN ( LR_obj o)

LRf_erlang_RAN(LR_obj *o) - float random negative exponential distribution using the inversion method. Default values: scale m = 1.

Parameters
oLR_obj object
Returns
float

Definition at line 142 of file LRerlang.c.