DistErlang
- class pydsol.core.distributions.DistErlang(stream: StreamInterface, scale: float, k: int)[source]
Bases:
DistContinuous
The Erlang distribution is the distribution of a sum of k independent exponential variables with the scale parameter as the mean. The scale parameter is equal to 1/rate or 1/lambda;, giving the entire Erlang distribution a mean of k*scale. For more information on this distribution see https://mathworld.wolfram.com/ErlangDistribution.html.
- GAMMATHRESHOLD = 10
the threshold above which we use a gamma function and below we use repeated drawing
- __init__(stream: StreamInterface, scale: float, k: int)[source]
Construct a new Erlang distribution with k and a mean (so not k and a rate) as parameters. It is the distribution of a sum of k independent exponential variables with the scale parameter as the mean. The scale parameter is equal to 1/rate or 1/lambda, giving the entire Erlang distribution a mean of k*scale.
- Parameters:
stream (StreamInterface) – the random stream to use for this distribution
scale (float) – the mean of a single sample from the exponential distribution, of which k are summed. Equal to 1/rate or 1/lambda.
k (int) – the shape parameter of the Erlang distribution. The shape k is the number of times a drawing is done from the exponential distribution, where the Erlang distribution is the sum of these k independent exponential variables.
- Raises:
TypeError – when stream is not implementing StreamInterface:
TypeError – when scale is not a float or int:
TypeError – when k is not an int:
ValueError – when k <= 0 or scale <= 0:
- draw() float [source]
Draw a value from the Erlang distribution. Based on the algorithm in Law & Kelton, Simulation Modeling and Analysis, 1991.
- property scale: float
Return the parameter value scale
- property k: int
Return the parameter value k
- property stream: StreamInterface
Return the current random stream for this distribution.