pub struct StatisticalDiffusionBackend { /* private fields */ }Expand description
A diffusion backend that generates samples matching target statistical properties.
The forward process adds Gaussian noise according to the noise schedule. The reverse process uses Langevin-inspired updates to guide samples toward the target distribution (means, standard deviations, correlations).
Implementations§
Source§impl StatisticalDiffusionBackend
impl StatisticalDiffusionBackend
Sourcepub fn new(means: Vec<f64>, stds: Vec<f64>, config: DiffusionConfig) -> Self
pub fn new(means: Vec<f64>, stds: Vec<f64>, config: DiffusionConfig) -> Self
Create a new statistical diffusion backend.
§Arguments
means- Target means for each feature dimensionstds- Target standard deviations for each feature dimensionconfig- Diffusion configuration (steps, schedule type, seed)
Sourcepub fn with_correlations(self, corr_matrix: Vec<Vec<f64>>) -> Self
pub fn with_correlations(self, corr_matrix: Vec<Vec<f64>>) -> Self
Set the correlation matrix for multi-dimensional generation.
The matrix should be symmetric positive-definite with ones on the diagonal. After denoising, Cholesky decomposition is used to impose this correlation structure on the generated samples.
Trait Implementations§
Source§impl Clone for StatisticalDiffusionBackend
impl Clone for StatisticalDiffusionBackend
Source§fn clone(&self) -> StatisticalDiffusionBackend
fn clone(&self) -> StatisticalDiffusionBackend
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 StatisticalDiffusionBackend
impl Debug for StatisticalDiffusionBackend
Source§impl DiffusionBackend for StatisticalDiffusionBackend
impl DiffusionBackend for StatisticalDiffusionBackend
Source§fn forward(&self, x: &[Vec<f64>], t: usize) -> Vec<Vec<f64>>
fn forward(&self, x: &[Vec<f64>], t: usize) -> Vec<Vec<f64>>
Forward process: add noise at timestep t.
x_t = sqrt(alpha_bar_t) * x_0 + sqrt(1 - alpha_bar_t) * noise
Source§fn reverse(&self, x_t: &[Vec<f64>], t: usize) -> Vec<Vec<f64>>
fn reverse(&self, x_t: &[Vec<f64>], t: usize) -> Vec<Vec<f64>>
Reverse process: denoise at timestep t using Langevin-inspired updates.
x_{t-1} = x_t - step_size * (x_t - mu) / sigma^2 + noise_scale * noise
Source§fn generate(
&self,
n_samples: usize,
n_features: usize,
seed: u64,
) -> Vec<Vec<f64>>
fn generate( &self, n_samples: usize, n_features: usize, seed: u64, ) -> Vec<Vec<f64>>
Generate n_samples with n_features by starting from pure noise and iteratively denoising using the reverse process.
At each reverse step t, the sample is updated via: x_{t-1} = (1 - blend) * x_t + blend * (mu + sigma * z) + noise where blend is derived from the schedule’s signal-to-noise progression, z is standard normal for stochastic variation, and noise decreases to zero at t=0.
Auto Trait Implementations§
impl Freeze for StatisticalDiffusionBackend
impl RefUnwindSafe for StatisticalDiffusionBackend
impl Send for StatisticalDiffusionBackend
impl Sync for StatisticalDiffusionBackend
impl Unpin for StatisticalDiffusionBackend
impl UnsafeUnpin for StatisticalDiffusionBackend
impl UnwindSafe for StatisticalDiffusionBackend
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.