distributions.Hyperexponential

Hyperexponential distribution implementation.

Usage

Source

distributions.Hyperexponential()

A continuous probability distribution that is a mixture (weighted sum) of exponential distributions. It has a higher coefficient of variation than a single exponential distribution, making it useful for modeling highly variable processes or heavy-tailed phenomena.

The hyperexponential distribution is useful to model service processes where customers may require fundamentally different types of service with varying durations. For example, in a technical support call center, customers might either:

  1. Have a simple issue (resolved quickly with rate λ₁) with probability p₁

  2. Have a complex issue (requiring longer service with rate λ₂) with probability p₂

This class conforms to the Distribution protocol and provides methods to sample from a hyperexponential distribution with specified phase probabilities and rates.

Attributes

Name Description
mean Calculate the theoretical mean of the distribution.
variance Calculate the theoretical variance of the distribution.

mean

Calculate the theoretical mean of the distribution.

mean: float


variance

Calculate the theoretical variance of the distribution.

variance: float

Methods

Name Description
__init__() Initialize a hyperexponential distribution.
__repr__() Return a string representation of the distribution.
sample() Generate random samples from the hyperexponential distribution.

__init__()

Initialize a hyperexponential distribution.

Usage

Source

__init__(probs, rates, random_seed=None)
Parameters
probs: ArrayLike

The probabilities (weights) of selecting each exponential component. Must sum to 1.0.

rates: ArrayLike

The rate parameters for each exponential component. Must be positive and same length as probs.

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

__repr__()

Return a string representation of the distribution.

Usage

Source

__repr__()

sample()

Generate random samples from the hyperexponential 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 hyperexponential distribution