pub struct AmountSampler { /* private fields */ }Expand description
Sampler for realistic transaction amounts.
Implementations§
Source§impl AmountSampler
impl AmountSampler
Sourcepub fn with_config(seed: u64, config: AmountDistributionConfig) -> Self
pub fn with_config(seed: u64, config: AmountDistributionConfig) -> Self
Create a sampler with custom configuration.
Sourcepub fn with_benford(seed: u64, config: AmountDistributionConfig) -> Self
pub fn with_benford(seed: u64, config: AmountDistributionConfig) -> Self
Create a sampler with Benford’s Law compliance enabled.
Sourcepub fn with_fraud_config(
seed: u64,
config: AmountDistributionConfig,
threshold_config: ThresholdConfig,
benford_enabled: bool,
) -> Self
pub fn with_fraud_config( seed: u64, config: AmountDistributionConfig, threshold_config: ThresholdConfig, benford_enabled: bool, ) -> Self
Create a sampler with full fraud configuration.
Sourcepub fn set_benford_enabled(&mut self, enabled: bool)
pub fn set_benford_enabled(&mut self, enabled: bool)
Enable or disable Benford’s Law compliance.
Sourcepub fn is_benford_enabled(&self) -> bool
pub fn is_benford_enabled(&self) -> bool
Check if Benford’s Law compliance is enabled.
Sourcepub fn sample(&mut self) -> Decimal
pub fn sample(&mut self) -> Decimal
Sample a single amount.
If Benford’s Law compliance is enabled, uses the Benford sampler. Otherwise uses log-normal distribution with round-number bias.
Sourcepub fn sample_lognormal(&mut self) -> Decimal
pub fn sample_lognormal(&mut self) -> Decimal
Sample using the log-normal distribution (original behavior).
Sourcepub fn sample_fraud(&mut self, pattern: FraudAmountPattern) -> Decimal
pub fn sample_fraud(&mut self, pattern: FraudAmountPattern) -> Decimal
Sample a fraud amount with the specified pattern.
Returns a normal amount if fraud generator is not configured.
Sourcepub fn sample_summing_to(
&mut self,
count: usize,
total: Decimal,
) -> Vec<Decimal>
pub fn sample_summing_to( &mut self, count: usize, total: Decimal, ) -> Vec<Decimal>
Sample multiple amounts that sum to a target total.
Useful for generating line items that must balance.
The sum of returned amounts is guaranteed to equal total exactly.
Every returned amount is guaranteed to be > 0 when total > 0 and
count * 0.01 <= total.
Sourcepub fn sample_in_range(&mut self, min: Decimal, max: Decimal) -> Decimal
pub fn sample_in_range(&mut self, min: Decimal, max: Decimal) -> Decimal
Sample an amount within a specific range.
Sourcepub fn set_lognormal_sigma(&mut self, sigma: f64)
pub fn set_lognormal_sigma(&mut self, sigma: f64)
SP3.5b — Update the log-normal sigma parameter.
Also rebuilds the internal LogNormal distribution so that subsequent
sample_lognormal() calls reflect the new sigma. No-op if sigma is
not positive (guard against calibrator edge-cases).
Sourcepub fn set_round_number_probability(&mut self, p: f64)
pub fn set_round_number_probability(&mut self, p: f64)
SP3.5b — Update the round-number probability parameter.
Clamped to [0, 1] for safety.
Sourcepub fn lognormal_sigma(&self) -> f64
pub fn lognormal_sigma(&self) -> f64
Return the current log-normal sigma (for testing).
Sourcepub fn round_number_probability(&self) -> f64
pub fn round_number_probability(&self) -> f64
Return the current round-number probability (for testing).
Auto Trait Implementations§
impl Freeze for AmountSampler
impl RefUnwindSafe for AmountSampler
impl Send for AmountSampler
impl Sync for AmountSampler
impl Unpin for AmountSampler
impl UnsafeUnpin for AmountSampler
impl UnwindSafe for AmountSampler
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.