pub struct ColoredNoiseGenerator<S: Scalar> { /* private fields */ }Expand description
Spatially correlated Gaussian noise generator.
Generates samples of Gaussian random fields with exponential (squared) correlation function:
C(x, y) = exp(-|x - y|^2 / (2 * L^2))where L is the correlation length. Uses Cholesky decomposition of the
correlation matrix to transform independent standard normal samples into
correlated samples.
Implementations§
Source§impl<S: Scalar> ColoredNoiseGenerator<S>
impl<S: Scalar> ColoredNoiseGenerator<S>
Sourcepub fn new(correlation_length: S, seed: u64) -> Self
pub fn new(correlation_length: S, seed: u64) -> Self
Create a new colored noise generator.
§Arguments
correlation_length- The spatial correlation lengthLseed- Random seed for reproducibility
Sourcepub fn sample(&mut self, grid: &[S]) -> Result<Vec<S>, String>
pub fn sample(&mut self, grid: &[S]) -> Result<Vec<S>, String>
Generate a sample of spatially correlated noise on the given grid.
Returns a vector of correlated Gaussian values, one per grid point. Adjacent grid points within the correlation length will have similar values.
Returns an error if the correlation matrix is not positive definite or is ill-conditioned for the given grid/correlation_length combination.
Auto Trait Implementations§
impl<S> Freeze for ColoredNoiseGenerator<S>where
S: Freeze,
impl<S> RefUnwindSafe for ColoredNoiseGenerator<S>where
S: RefUnwindSafe,
impl<S> Send for ColoredNoiseGenerator<S>
impl<S> Sync for ColoredNoiseGenerator<S>
impl<S> Unpin for ColoredNoiseGenerator<S>where
S: Unpin,
impl<S> UnsafeUnpin for ColoredNoiseGenerator<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for ColoredNoiseGenerator<S>where
S: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more