distributions.RawDiscreteEmpirical
Raw Empirical distribution implementation.
Usage
distributions.RawDiscreteEmpirical()Samples with replacement from a list of empirical values. Useful when no theoretical distribution fits the observed data well.
This class conforms to the Distribution protocol.
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 raw empirical distribution. |
| sample() | Generate random samples from the raw empirical data with replacement. |
__init__()
Initialize a raw empirical distribution.
Usage
__init__(values, random_seed=None)Parameters
values: ArrayLike-
List of empirical sample values to sample from with replacement.
random_seed: Optional[Union[int, SeedSequence]] = None- A random seed or SeedSequence to reproduce samples. If None, a unique sample sequence is generated.
Notes
If the sample size is small, consider whether the upper and lower limits in the raw data are representative of the real-world system.
sample()
Generate random samples from the raw empirical data with replacement.
Usage
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 empirical data:
- A single value when size is None
- A numpy array of values with shape determined by size parameter