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.