I'm learning about sampling and DSP on my own. I have a hard time to understand how the quantization error results in noise. I think I miss a fundamental understanding but can't tell what it is. So how does the quantization error generate noise?
Suppose I have a multitone signal (six carriers, at ±1/1000, ±2/1000 and ±7/1000 of sampling frequency)
x = (1:1000); wave = sin(x/1000*2*pi) + sin(x/1000*2*pi*2) + sin(x/1000*2*pi*7);
which is quantized using a 14-bit ADC
wave_quant = round(wave * 16384) / 16384;
wave_qnoise = wave_quant - wave;
gives the quantization error
The corresponding spectrum
wave_qnoise_freq = mag(fftshift(fft(wave_qnoise)) / sqrt(1000));
shows the generated noise floor across the entire spectrum.
This assumes that the quantization error does not introduce a bias. If the ADC always chooses the lower value
wave_quant_biased = floor(wave * 16384) / 16384;
we get a quantization error that is no longer centered around zero
wave_qnoise_biased = wave_quant_biased - wave;
which has a definite spike in the FFT in the DC bin
wave_qnoise_biased_freq = mag(fftshift(fft(wave_qnoise_biased)) / sqrt(1000));
This becomes a real problem with e.g. Quadrature Amplitude Modulation, where a DC offset in the demodulated signal corresponds to a sine wave at the demodulation frequency.
"Noise" in this context refers to anything unwanted added to the signal, it doesn't necessarily mean it is gaussian noise, white noise, or any random well-described process.
In the context of quantization, it is a purely algebraic argument. One can view quantization as the addition of an unwanted signal ("noise") equal to... the difference between the original signal and the quantized signal. Note that this quantification noise is not random, and is correlated with the input signal. For example, if a signal is periodic, the quantization noise introduced when quantizing it will be periodic too.
To expand on what pichenettes said, consider if you have an audio signal that is being digitized by a D-to-A converter that only has a resolution of 0.01 volt. If, at some particular instant in time, the audio signal is at 7.3269 volts, that will be either rounded to 7.33 volts or truncated to 7.32 volts (depending on the design of the converter). In the first case you've added "noise" of 7.33-7.3269 volts, or 0.0031 volt. In the second case you've added "noise" of 7.32-7.3269 volts, or -0.0069 volt.
Of course, there is additional noise added due to the fact that the converter is most certainly not infinitely accurate, and probably has an accuracy on par with its precision.
Here is a more basic explanation to get the fundamental point across.
- Reach in your pocket and take out your iPhone.
- Open Health app -> Fitness Activity -> Steps walked (this is turned on by default).
- Write down how many steps you walked during each of the past ten days.
Round those numbers to the thousands and post them here. Now the other people here have to guess your original numbers based on what you posted.
Other people cannot reliably guess the exact number based on the rounded number you provided. That's data loss. And in this case (because you used rounding) that is called quantization error.