comnum.awgn#

comnum.awgn(x, snr_db, rng, *, fs=1.0, bandwidth_hz=1.0)#

Add circular complex Gaussian noise for an SNR of snr_db within the bandwidth bandwidth of a signal sampled at fs (OptiCommPy awgn): σ² = (fs/bandwidth) P_x / SNR.

Parameters:
  • x (array_like) – the signal.

  • snr_db (float) – the SNR (dB).

  • rng (Rng) – the generator.

  • fs (float) – sampling rate (Hz).

  • bandwidth_hz (float) – the bandwidth of the SNR (Hz); with the default fs = 1, bandwidth_hz = 1, the SNR is per sample.

Returns:

the noisy signal (complex128).

Return type:

numpy.ndarray

Raises:

ValueError – for an input that is not an array of numbers of the expected shape.

Examples

>>> import comnum, numpy as np
>>> x = np.ones(100_000, dtype=complex)
>>> y = comnum.awgn(x, 10.0, comnum.Rng(1))
>>> round(comnum.snr_db(y, x))
10