pub struct TemporalSampler { /* private fields */ }Expand description
Sampler for temporal patterns in transaction generation.
Implementations§
Source§impl TemporalSampler
impl TemporalSampler
Sourcepub fn with_config(
seed: u64,
seasonality_config: SeasonalityConfig,
working_hours_config: WorkingHoursConfig,
holidays: Vec<NaiveDate>,
) -> Self
pub fn with_config( seed: u64, seasonality_config: SeasonalityConfig, working_hours_config: WorkingHoursConfig, holidays: Vec<NaiveDate>, ) -> Self
Create a temporal sampler with custom configuration.
Sourcepub fn with_full_config(
seed: u64,
seasonality_config: SeasonalityConfig,
working_hours_config: WorkingHoursConfig,
holidays: Vec<NaiveDate>,
industry_seasonality: Option<IndustrySeasonality>,
holiday_calendar: Option<HolidayCalendar>,
) -> Self
pub fn with_full_config( seed: u64, seasonality_config: SeasonalityConfig, working_hours_config: WorkingHoursConfig, holidays: Vec<NaiveDate>, industry_seasonality: Option<IndustrySeasonality>, holiday_calendar: Option<HolidayCalendar>, ) -> Self
Create a temporal sampler with full enhanced configuration.
Sourcepub fn with_period_end_dynamics(
seed: u64,
seasonality_config: SeasonalityConfig,
working_hours_config: WorkingHoursConfig,
holidays: Vec<NaiveDate>,
industry_seasonality: Option<IndustrySeasonality>,
holiday_calendar: Option<HolidayCalendar>,
period_end_dynamics: PeriodEndDynamics,
) -> Self
pub fn with_period_end_dynamics( seed: u64, seasonality_config: SeasonalityConfig, working_hours_config: WorkingHoursConfig, holidays: Vec<NaiveDate>, industry_seasonality: Option<IndustrySeasonality>, holiday_calendar: Option<HolidayCalendar>, period_end_dynamics: PeriodEndDynamics, ) -> Self
Create a temporal sampler with period-end dynamics.
Sourcepub fn set_intra_day_patterns(&mut self, patterns: IntraDayPatterns)
pub fn set_intra_day_patterns(&mut self, patterns: IntraDayPatterns)
Sets the intra-day patterns for time-of-day activity variation.
Sourcepub fn get_intra_day_multiplier(&self, time: NaiveTime, is_human: bool) -> f64
pub fn get_intra_day_multiplier(&self, time: NaiveTime, is_human: bool) -> f64
Gets the intra-day multiplier for a given time.
Sourcepub fn with_industry_seasonality(self, seasonality: IndustrySeasonality) -> Self
pub fn with_industry_seasonality(self, seasonality: IndustrySeasonality) -> Self
Set industry-specific seasonality.
Sourcepub fn with_holiday_calendar(self, calendar: HolidayCalendar) -> Self
pub fn with_holiday_calendar(self, calendar: HolidayCalendar) -> Self
Set regional holiday calendar.
Sourcepub fn set_industry_seasonality(&mut self, seasonality: IndustrySeasonality)
pub fn set_industry_seasonality(&mut self, seasonality: IndustrySeasonality)
Set industry seasonality (mutable reference version).
Sourcepub fn set_holiday_calendar(&mut self, calendar: HolidayCalendar)
pub fn set_holiday_calendar(&mut self, calendar: HolidayCalendar)
Set holiday calendar (mutable reference version).
Sourcepub fn with_period_end(self, dynamics: PeriodEndDynamics) -> Self
pub fn with_period_end(self, dynamics: PeriodEndDynamics) -> Self
Set period-end dynamics.
Sourcepub fn set_period_end_dynamics(&mut self, dynamics: PeriodEndDynamics)
pub fn set_period_end_dynamics(&mut self, dynamics: PeriodEndDynamics)
Set period-end dynamics (mutable reference version).
Sourcepub fn period_end_dynamics(&self) -> Option<&PeriodEndDynamics>
pub fn period_end_dynamics(&self) -> Option<&PeriodEndDynamics>
Get the period-end dynamics if set.
Sourcepub fn set_use_period_end_dynamics(&mut self, enabled: bool)
pub fn set_use_period_end_dynamics(&mut self, enabled: bool)
Enable or disable period-end dynamics usage.
Sourcepub fn industry_seasonality(&self) -> Option<&IndustrySeasonality>
pub fn industry_seasonality(&self) -> Option<&IndustrySeasonality>
Get the industry seasonality if set.
Sourcepub fn holiday_calendar(&self) -> Option<&HolidayCalendar>
pub fn holiday_calendar(&self) -> Option<&HolidayCalendar>
Get the holiday calendar if set.
Sourcepub fn generate_us_holidays(year: i32) -> Vec<NaiveDate>
pub fn generate_us_holidays(year: i32) -> Vec<NaiveDate>
Generate US federal holidays for a given year.
Sourcepub fn is_weekend(&self, date: NaiveDate) -> bool
pub fn is_weekend(&self, date: NaiveDate) -> bool
Check if a date is a weekend.
Sourcepub fn get_day_of_week_multiplier(&self, date: NaiveDate) -> f64
pub fn get_day_of_week_multiplier(&self, date: NaiveDate) -> f64
Get the day-of-week activity multiplier.
Returns a multiplier based on the day of the week:
- Monday: Higher activity (catch-up from weekend)
- Tuesday: Slightly elevated
- Wednesday/Thursday: Normal
- Friday: Reduced (early departures, winding down)
- Saturday/Sunday: Uses weekend_activity setting
Sourcepub fn is_holiday(&self, date: NaiveDate) -> bool
pub fn is_holiday(&self, date: NaiveDate) -> bool
Check if a date is a holiday.
Sourcepub fn is_month_end(&self, date: NaiveDate) -> bool
pub fn is_month_end(&self, date: NaiveDate) -> bool
Check if a date is month-end (last N days of month).
Sourcepub fn is_quarter_end(&self, date: NaiveDate) -> bool
pub fn is_quarter_end(&self, date: NaiveDate) -> bool
Check if a date is quarter-end.
Sourcepub fn is_year_end(&self, date: NaiveDate) -> bool
pub fn is_year_end(&self, date: NaiveDate) -> bool
Check if a date is year-end.
Sourcepub fn last_day_of_month(date: NaiveDate) -> NaiveDate
pub fn last_day_of_month(date: NaiveDate) -> NaiveDate
Get the last day of the month for a given date.
Sourcepub fn get_date_multiplier(&self, date: NaiveDate) -> f64
pub fn get_date_multiplier(&self, date: NaiveDate) -> f64
Get the activity multiplier for a specific date.
Combines:
- Base seasonality (month-end, quarter-end, year-end spikes)
- Day-of-week patterns (Monday catch-up, Friday slowdown)
- Weekend activity reduction
- Holiday activity reduction (from calendar or legacy list)
- Industry-specific seasonality (if configured)
- Period-end dynamics (if configured, replaces legacy flat multipliers)
Sourcepub fn get_period_end_multiplier(&self, date: NaiveDate) -> f64
pub fn get_period_end_multiplier(&self, date: NaiveDate) -> f64
Get the period-end multiplier for a date.
Returns the period-end component of the date multiplier, using dynamics if available, otherwise legacy flat multipliers.
Sourcepub fn get_base_date_multiplier(&self, date: NaiveDate) -> f64
pub fn get_base_date_multiplier(&self, date: NaiveDate) -> f64
Get the base multiplier without industry seasonality.
Sourcepub fn get_industry_multiplier(&self, date: NaiveDate) -> f64
pub fn get_industry_multiplier(&self, date: NaiveDate) -> f64
Get only the industry seasonality multiplier for a date.
Sourcepub fn sample_date(&mut self, start: NaiveDate, end: NaiveDate) -> NaiveDate
pub fn sample_date(&mut self, start: NaiveDate, end: NaiveDate) -> NaiveDate
Sample a posting date within a range based on seasonality.
Uses a cached cumulative distribution function (CDF) to avoid recomputing date weights on every call. The CDF is computed once for a given (start, end) range and reused for subsequent calls.
Sourcepub fn sample_time(&mut self, is_human: bool) -> NaiveTime
pub fn sample_time(&mut self, is_human: bool) -> NaiveTime
Sample a posting time based on working hours.
Sourcepub fn expected_count_for_date(
&self,
date: NaiveDate,
daily_average: f64,
) -> u64
pub fn expected_count_for_date( &self, date: NaiveDate, daily_average: f64, ) -> u64
Calculate expected transaction count for a date given daily average.
Auto Trait Implementations§
impl Freeze for TemporalSampler
impl RefUnwindSafe for TemporalSampler
impl Send for TemporalSampler
impl Sync for TemporalSampler
impl Unpin for TemporalSampler
impl UnsafeUnpin for TemporalSampler
impl UnwindSafe for TemporalSampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.