pub struct SourceConditionalPairSampler { /* private fields */ }Expand description
Top-level sampler — one SourcePool per source string.
Implementations§
Source§impl SourceConditionalPairSampler
impl SourceConditionalPairSampler
Sourcepub fn new(
sources: &[String],
all_accounts: &[String],
account_weights: &[f64],
accts_per_source_target: usize,
alpha: f64,
rng: &mut ChaCha8Rng,
) -> Self
pub fn new( sources: &[String], all_accounts: &[String], account_weights: &[f64], accts_per_source_target: usize, alpha: f64, rng: &mut ChaCha8Rng, ) -> Self
Build a sampler for every source in sources. Each gets a pool of
approximately accts_per_source_target accounts (multiplied by a LogNormal(0,
0.3) jitter so the per-source pool size has corpus-like variance), drawn from
all_accounts weighted by account_weights, with PMF ∼ Dir(α).
Sourcepub fn pool(&self, source: &str) -> Option<&SourcePool>
pub fn pool(&self, source: &str) -> Option<&SourcePool>
Get the per-source pool (for diagnostics / tests).
Sourcepub fn ensure_pool(
&mut self,
source: &str,
all_accounts: &[String],
account_weights: &[f64],
accts_per_source_target: usize,
alpha: f64,
rng: &mut ChaCha8Rng,
) -> bool
pub fn ensure_pool( &mut self, source: &str, all_accounts: &[String], account_weights: &[f64], accts_per_source_target: usize, alpha: f64, rng: &mut ChaCha8Rng, ) -> bool
Lazy-add a per-source pool if one isn’t already present. Returns true iff a
new pool was inserted; false if source was already pooled (no-op). Uses the
same LogNormal(0, 0.3) jitter on the pool size as new, so a sampler built up
one source at a time has the same distribution as one built with all sources
at once.
Sourcepub fn sample_pair(
&self,
source: &str,
rng: &mut ChaCha8Rng,
) -> Option<(String, String)>
pub fn sample_pair( &self, source: &str, rng: &mut ChaCha8Rng, ) -> Option<(String, String)>
Sample a (debit_account, credit_account) pair conditioned on source.
Returns None if the source isn’t in the sampler — the caller should fall back
to the existing global account picker.
pub fn is_empty(&self) -> bool
pub fn n_sources(&self) -> usize
Trait Implementations§
Source§impl Clone for SourceConditionalPairSampler
impl Clone for SourceConditionalPairSampler
Source§fn clone(&self) -> SourceConditionalPairSampler
fn clone(&self) -> SourceConditionalPairSampler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SourceConditionalPairSampler
impl Debug for SourceConditionalPairSampler
Source§impl Default for SourceConditionalPairSampler
impl Default for SourceConditionalPairSampler
Source§fn default() -> SourceConditionalPairSampler
fn default() -> SourceConditionalPairSampler
Auto Trait Implementations§
impl Freeze for SourceConditionalPairSampler
impl RefUnwindSafe for SourceConditionalPairSampler
impl Send for SourceConditionalPairSampler
impl Sync for SourceConditionalPairSampler
impl Unpin for SourceConditionalPairSampler
impl UnsafeUnpin for SourceConditionalPairSampler
impl UnwindSafe for SourceConditionalPairSampler
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.