## distributions.Hyperexponential


Hyperexponential distribution implementation.


Usage

``` python
distributions.Hyperexponential(
    probs,
    rates,
    random_seed=None,
)
```


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](#mean) | Calculate the theoretical mean of the distribution. |
| [variance](#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__()](#__init__) | Initialize a hyperexponential distribution. |
| [__repr__()](#__repr__) | Return a string representation of the distribution. |
| [sample()](#sample) | Generate random samples from the hyperexponential distribution. |

------------------------------------------------------------------------


#### \_\_init\_\_()


Initialize a hyperexponential distribution.


Usage

``` python
__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

``` python
__repr__()
```


------------------------------------------------------------------------


#### sample()


Generate random samples from the hyperexponential distribution.


Usage

``` python
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
