distributions
distributions
¶
Statistical distribution models for sampling numeric and datetime values.
Provides Distribution (float-valued) and DatetimeDistribution
hierarchies, each with Gaussian and Uniform concrete implementations.
Pydantic discriminated unions (DistributionT, DatetimeDistributionT)
allow YAML/JSON configs to select the distribution type via distribution_type.
Classes:
| Name | Description |
|---|---|
Distribution |
Abstract base for float-valued distributions. |
DatetimeDistribution |
Abstract base for datetime-valued distributions. |
Distribution
pydantic-model
¶
Bases: BaseModel, ABC
Abstract base for float-valued distributions.
Subclasses specify the parameters needed to define their distribution
and implement sample to draw values.
DatetimeDistribution
pydantic-model
¶
Bases: BaseModel, ABC
Abstract base for datetime-valued distributions.
Separate from Distribution because datetime parameters (datetime,
timedelta) differ from floats, and pydantic validation benefits from
distinct type hierarchies. Subclasses implement sample_datetimes to
produce raw datetime samples; universal post-processing (rounding via
precision, formatting via format) is applied by sample.
Fields:
precision = None
pydantic-field
¶
precision controls how we precisely want to round the dates.
Most DatetimeDistributions sample from their distribution by first
sampling from an underlying float-based distribution. When this is then converted
back into datetimes, these datetimes always have specific hours/minutes/seconds.
precision is technically a timedelta field, so the timedelta you pass in
is the unit to which the datetimes will be rounded to. If invoking a distribution
via json/yaml, look at pydantic's timedelta parsing:
https://docs.pydantic.dev/2.2/usage/types/datetime/
Examples:
precision: 00:10 # rounded to nearest 10 minutes precision: 01:00 # rounded to nearest hour precision: 1 # rounded to whole day
format = None
pydantic-field
¶
format will determine the string output format of the generated datetimes.
The expected strings match inputs to the strftime function.