distributions.Erlang

Erlang distribution implementation.

Usage

Source

distributions.Erlang()

A continuous probability distribution that is a special case of the Gamma distribution where the shape parameter is an integer. This implementation allows users to specify mean and standard deviation rather than shape (k) and scale (theta) parameters.

This class conforms to the Distribution protocol and provides methods to sample from an Erlang distribution with specified parameters.

Notes

The Erlang is a special case of the gamma distribution where k is an integer. Internally this is implemented using numpy Generator’s gamma method. The k parameter is calculated from the mean and standard deviation and rounded to an integer.

Sources

Conversion between mean+stdev to k+theta: https://www.statisticshowto.com/erlang-distribution/

Methods

Name Description
__init__() Initialize an Erlang distribution.
sample() Generate random samples from the Erlang distribution.

__init__()

Initialize an Erlang distribution.

Usage

Source

__init__(mean, stdev, location=0.0, random_seed=None)
Parameters
mean: float

Mean of the Erlang distribution.

stdev: float

Standard deviation of the Erlang distribution.

location: float = 0.0

Offset the origin of the distribution. The returned value will be the sampled value plus this location parameter.

random_seed: Optional[Union[int, SeedSequence]] = None
A random seed or SeedSequence to reproduce samples. If None, a unique sample sequence is generated.

sample()

Generate random samples from the Erlang distribution.

Usage

Source

sample(size=None)
Parameters
size: Optional[Union[int, Tuple[int, …]]] = None
The number/shape of samples to generate:
  • If None: returns a single sample as a float
  • If int: returns a 1-D array with that many samples
  • If tuple of ints: returns an array with that shape
Returns
Union[float, NDArray[np.float64]]
Random samples from the Erlang distribution:
  • A single float when size is None
  • A numpy array of floats with shape determined by size parameter