3. Noise#

class Noise#

Bases: object

Generates noise for measurements and other data, primarily focusing on Additive White Gaussian Noise (AWGN). This class provides methods to generate AWGN with and without units, as well as to apply AWGN to existing datasets.

See also

scarabaeus.Units

Defines units for data and noise.

scarabaeus.ArrayWUnits

Represents arrays with units.

Notes

The generated noise follows a normal distribution with specified mean (mu) and standard deviation (sigma).

When applying noise to data, the resulting noisy dataset maintains the original data units.

This implementation relies on numpy for random sampling.

References

Grimmett, Geoffrey; David Stirzaker (2001). Probability and Random Processes. Oxford University Press. ISBN 978-0198572220.

Methods

apply_AWGN(data, mu, sigma)

Apply Additive White Gaussian Noise to a set of data.

generate_AWGN(mu, sigma[, count])

Generates an array of Additive White Gaussian Noise of size specified by count.

generate_AWGN_with_units(mu, sigma, units[, ...])

Generates an array of Additive White Gaussian Noise with the given units and specified size.

apply_AWGN(data: ArrayWUnits, mu: float, sigma: float) ArrayWUnits#

Apply Additive White Gaussian Noise to a set of data.

The noise will be of the same unit type as the data sampled from a normal distribution with mean mu and standard deviation sigma.

Parameters:
  • data (ArrayWUnits) – The data to which noise will be added.

  • mu (float) – The mean of the normal distribution being sampled from.

  • sigma (float) – The standard Deviation of the normal distribution being sampled from.

Returns:

noise – New, noisy data

Return type:

ArrayWUnits

generate_AWGN(mu: float, sigma: float, count: int = 1) ndarray#

Generates an array of Additive White Gaussian Noise of size specified by count. This function returns an array of unitless noise values.

Count defaults to 1 but can be specified to be of arbitrary length.

Parameters:
  • mu (float) – The mean of the normal distribution being sampled from.

  • sigma (float) – The standard deviation of the normal distribution being sampled from.

  • count (int, optional) – The length of noise array. Defaults to 1.

Returns:

noise – Generated noise values with no units.

Return type:

numpy.ndarray

generate_AWGN_with_units(mu: float, sigma: float, units: Units, count: int = 1) ArrayWUnits#

Generates an array of Additive White Gaussian Noise with the given units and specified size.

Parameters:
  • mu (float) – The mean of the normal distribution being sampled from.

  • sigma (float) – The standard deviation of the normal distribution being sampled from.

  • units (Units) – The units of the noise.

  • count (int, optional) – The length of noise array. Defaults to 1.

Returns:

noise – Generated noise values with given units.

Return type:

ArrayWUnits