spyrit.core.noise.Gaussian.forward

Gaussian.forward(z)[source]

Simulates measurements corrupted by additive Gaussian noise

\[y \sim \mathcal{N}\left(\mu = z, \sigma^2\right),\]

where \(\mathcal{N}(\mu, \sigma^2)\) is a Gaussian distribution with mean \(\mu\) and variance \(\sigma^2\) and \(z\) are the noiseless measurements.

Args:

z (torch.tensor): Noiseless measurements \(z\) with arbitrary shape.

Output:

torch.tensor: Noisy measurement \(y\) with the same shape as z.

Example:

Two different noisy measurement vectors

>>> import spyrit.core.noise as sn
>>> import torch
>>> noise = sn.Gaussian(0.1)
>>> z = torch.empty(10, 4).uniform_(1, 2)
>>> y = noise(z)
>>> print(y.shape)
torch.Size([10, 4])
>>> print(f"Measurements in ({torch.min(y):.2f} , {torch.max(y):.2f})")
Measurements in (...)
>>> y = noise(z)
>>> print(f"Measurements in ({torch.min(y):.2f} , {torch.max(y):.2f})")
Measurements in (...)