Quantization

The A/D and D/A converters together represent quantization. Since we can only hope to approximate a real number with a finite set of values, quantization adds an error. We can now characterize that error. Using the Mathematica Round[] routine, we can easily define the quantization function.

In[16]:=

  Q[x_] := If[ -1<=x<=+1,
             Round[x (2^(Nbits-1)-1)]/(2^(Nbits-1)-1),
             If[ x<-1, -1, 1]
             ];

Here is a three-bit uniform quantizer (approximating a real number with seven values):

In[17]:=

  Nbits=3; Plot[Q[x],{x,-2,2}];

When we use five bits, the approximation is better:

In[18]:=

  Nbits=5; Plot[Q[x],{x,-2,2}];

We can also plot the error, first for three bits:

In[19]:=

  Nbits=3; Plot[x-Q[x],{x,-1.2,1.2}];

And then for five bits:

In[20]:=

  Nbits=5; Plot[x-Q[x],{x,-1.05,1.05}];

Note especially that the quantization error is smaller in the latter case.

In[21]:=

  Nbits=3; Plot[Q[Sin[2Pi t]],{t,0,2}];

In[22]:=

  Nbits=5; Plot[Q[Sin[2Pi t]],{t,0,2}];

Subjective impact of quantization error

Up to Digital and Quantization