问题
In general when we add noise to a signal x=rand(1,100)
, this is one way
sigma_2_v = 0.5;
noisy_signal = rand(1,100) + sqrt(sigma_2_v)*randn(1,100);
There is another method found here: Proper way to add noise
For my case, I need to have the information about the variance of the noise, sigma_2_v
, and generate noisy signal by varying sigma_2_v
. How can I do that?
回答1:
There are a number of possible conventions used to define a s/n ratio, a common one being based on the notion of signal and noise power. If the total power of the spectrum is p
and the noise power is np
, then the signal-to-noise can be written as snr = p - np
, when the power is in dB units, or snr = p/np
, when the power is in linear units.
The MATLAB (and Octave equivalent) function awgn
adds (white Gaussian) noise to an input data array to the desired final s/n power level, specified by default in dB. The function awgn
uses another function wgn
to generate an array representing the noise at a desired noise power level. The noise is sampled from a Gaussian distribution (it is not rescaled to make the variance of the points in the array equal exactly the desired noise power level, as some suggest you do; do not rescale the noise: if you rescale the points sampled from the noise distribution, then the points will (obviously) not necessarily reflect the desired noise distribution or the desired power level!). You can specify the amount of noise to add to your data via awgn
in a number of non-default ways, for instance: a) by specifying the power of the input data (the default is 0 dB), or b) by asking the routine to compute the power of the input data using the formula p = var(data,1)
, where var(...,1) implies computation of the population variance. In either case the routine computes the required noise power level using the formula np = p-snr
(in dB).
The excellent MATLAB documentation provides a good description of the awgn routine.
来源:https://stackoverflow.com/questions/29240096/matlab-generate-noisy-signal-for-particular-snr-and-particular-variance