## distributions.ErlangK


Erlang distribution where k and theta are specified.


Usage

``` python
distributions.ErlangK(
    k,
    theta,
    location=0.0,
    random_seed=None,
)
```


The Erlang is a special case of the gamma distribution where k is a positive integer. Internally this is implemented using numpy Generator's gamma method.

Optionally a user can offset the origin of the distribution using the location parameter.


## Attributes

| Name | Description |
|----|----|
| [mean](#mean) | Theoretical mean of the Erlang-K distribution. |
| [variance](#variance) | Theoretical variance of the Erlang-K distribution. |

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


#### mean


Theoretical mean of the Erlang-K distribution.


`mean: float`


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


#### variance


Theoretical variance of the Erlang-K distribution.


`variance: float`


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize an Erlang distribution with specified k and theta. |
| [sample()](#sample) | Generate random samples from the Erlang distribution. |

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


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


Initialize an Erlang distribution with specified k and theta.


Usage

``` python
__init__(k, theta, location=0.0, random_seed=None)
```


##### Parameters


`k: int`  
Shape parameter (positive integer) of the Erlang distribution.

`theta: float`  
Scale parameter of the Erlang distribution.

`location: float = ``0.0`  
Offset the origin of the distribution i.e. the returned value = sample\[Erlang\] + location

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


##### Raises


`ValueError`  
If k is not a positive integer.


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


#### sample()


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

- A single float when size is None
- A numpy array of floats with shape determined by size parameter
