## distributions.DiscreteEmpirical


DiscreteEmpirical distribution implementation.


Usage

``` python
distributions.DiscreteEmpirical(
    values,
    freq,
    random_seed=None,
)
```


A probability distribution that samples values with specified frequencies. Useful for modeling categorical data or discrete outcomes with known probabilities.


## Example Uses:

1.  Routing percentages
2.  Classes of entity
3.  Batch sizes of arrivals


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize a discrete distribution. |
| [sample()](#sample) | Generate random samples from the discrete distribution. |

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


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


Initialize a discrete distribution.


Usage

``` python
__init__(values, freq, random_seed=None)
```


##### Parameters


`values: ArrayLike`  
List of possible outcome values. Must be of equal length to freq.

`freq: ArrayLike`  
List of observed frequencies or probabilities. Must be of equal length to values. These will be normalized to sum to 1.

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


##### Raises


`TypeError`  
If freq is not a positive array.

`ValueError`  
If values and freq have different lengths.


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


#### sample()


Generate random samples from the discrete 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
- If int: returns a 1-D array with that many samples
- If tuple of ints: returns an array with that shape


##### Returns


`Union[Any, NDArray]`  
Random samples from the discrete distribution:

- A single value (of whatever type was in the values array) when size is None
- A numpy array of values with shape determined by size parameter
