Noise#
- class Noise#
Bases:
objectGenerates AWGN noise for measurements and sensor data.
Provides methods to draw independent samples from a univariate normal distribution with mean \(\mu\) and standard deviation \(\sigma\),
\[p(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\!\left(-\frac{(x - \mu)^2}{2\sigma^2}\right)\]returning unitless arrays, unit-carrying
ArrayWUnitsobjects, or noisy copies of existing datasets.See also
scarabaeus.UnitsUnit system used to annotate noise samples.
scarabaeus.ArrayWUnitsArray type that carries physical units.
Notes
All samples are drawn via
numpy.random.normal. Seed the global NumPy random state before calling any method for reproducible results. The noisy output ofapply_AWGN()preserves the units of the input data.References
Grimmett, G.; Stirzaker, D. (2001). Probability and Random Processes (3rd ed.). Oxford University Press. ISBN 978-0198572220.
Methods
apply_AWGN(data, mu, sigma)Apply AWGN to an existing dataset, preserving its physical units.
generate_AWGN(mu, sigma[, count])Generate an array of unitless Additive White Gaussian Noise samples.
generate_AWGN_with_units(mu, sigma, units[, ...])Generate an AWGN array annotated with physical units.
- apply_AWGN(data: ArrayWUnits, mu: float, sigma: float) ArrayWUnits#
Apply AWGN to an existing dataset, preserving its physical units.
Generates \(n = \texttt{data.size}\) noise samples \(\epsilon_i \sim \mathcal{N}(\mu,\,\sigma^2)\) in the same units as data, then returns \(\tilde{y}_i = y_i + \epsilon_i\).
- Parameters:
data (
ArrayWUnits) – Original dataset to corrupt.mu (
float) – Mean of the noise distribution (typically0).sigma (
float) – Standard deviation of the noise distribution.
- Returns:
noisy_data – Corrupted copy of data with units unchanged.
- Return type:
- generate_AWGN(mu: float, sigma: float, count: int = 1) ndarray#
Generate an array of unitless Additive White Gaussian Noise samples.
Each sample \(x_i \sim \mathcal{N}(\mu,\,\sigma^2)\) is drawn independently.
- Parameters:
- Returns:
noise – Array of shape
(count,)containing the noise samples.- Return type:
- generate_AWGN_with_units(mu: float, sigma: float, units: Units, count: int = 1) ArrayWUnits#
Generate an AWGN array annotated with physical units.
Delegates sampling to
generate_AWGN()and wraps the result in anArrayWUnitsobject.- Parameters:
- Returns:
noise – Array of shape
(count,)with the specified units.- Return type: