Skip to main content
Library homepage
Loading table of contents menu...
Workforce LibreTexts

5.1: Representation of digital and analog values - Sampling and Quantization

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    This section introduces the learner to sampling and quantization. This is where signals are represented into horizontal and vertical values (axes).

    Activity Details

    Analog and Digital Signals

    Digitalization of an analog signal involves two operations:

    1. Sampling, and
    2. Quantization

    Analog signals consist of continuous values for both axes. Consider an electrical signal whose horizontal axis represents time in seconds and whose vertical axis represents amplitude in volts. The horizontal axis has a range of values from zero to infinity with every possible value in between. This makes the horizontal axis continuous. The vertical axis is also continuous allowing the signal’s amplitude to assume any value from zero to infinity. For every possible value in time there is a corresponding value in amplitude for the analog signal.

    An analog signal exists throughout a continuous interval of time and/or takes on a continuous range of values. A sinusoidal signal (also called a pure tone in acoustics) has both of these properties.

    Fig 1: Analog signal. This signal \(v(t)=\cos (2\pi ft)\) could be a perfect analog recording of a pure tone of frequency \(f\) Hz. If \(f=440\) Hz, this tone is the musical note \(A\) above middle \(C\), to which orchestras often tune their instruments. The period \(T=1/f\) is the duration of one full oscillation.

    In reality, electrical recordings suffer from noise that unavoidably degrades the signal. The more a recording is transferred from one analog format to another, the more it loses fidelity to the original.

    Fig. 2: Noisy analog signal. Noise degrades the sinusoidal signal in Fig. 1. It is often impossible to recover the original signal exactly from the noisy version.

    Digital signals on the other hand have discrete values for both the horizontal and vertical axes. The axes are no longer continuous as they were with the analog signal. In this discussion, time

    will be used as the quantity for the horizontal axis and volts will be used for the vertical axis.

    A digital signal is a sequence of discrete symbols. If these symbols are zeros and ones, we call them bits. As such, a digital signal is neither continuous in time nor continuous in its range of values. And, therefore, cannot perfectly represent arbitrary analog signals. On the other hand, digital signals are resilient against noise.

    Fig. 3: Analog transmission of a digital signal. Consider a digital signal 100110 converted to an analog signal for radio transmission. The received signal suffers from noise, but given sufficient bit duration Tb, it is still easy to read off the original sequence 100110 perfectly.

    Digital signals can be stored on digital media (like a compact disc) and manipulated on digital systems (like the integrated circuit in a CD player). This digital technology enables a variety of digital processing unavailable to analog systems. For example, the music signal encoded on a CD includes additional data used for digital error correction. In case the CD is scratched and some of the digital signal becomes corrupted, the CD player may still be able to reconstruct the missing bits exactly from the error correction data. To protect the integrity of the data despite being stored on a damaged device, it is common to convert analog signals to digital signals using steps called sampling and quantization.

    Introduction to Sampling

    The motivation for sampling and quantizing is the need to store a signal in a digital format. In order to convert an analog signal to a digital signal, the analog signal must be sampled and quantized. Sampling takes the analog signal and discretizes the time axis. After sampling, the time axis consists of discrete points in time rather than continuous values in time. The resulting signal after sampling is called a discrete signal, sampled signal, or a discrete-time signal. The resulting signal after sampling is not a digital signal. Even though the horizontal axis has discrete values the vertical axis is not discretized. This means that for any discrete point in time, there are an infinite number of allowed values for the signal to assume in amplitude. In order for the signal to be a digital signal, both axes must be discrete.

    Sampling is the process of recording an analog signal at regular discrete moments of time. The sampling rate fs is the number of samples per second. The time interval between samples

    is called the sampling interval \(T_s=1/fs\).

    Fig. 4: Sampling. The signal \(v(t)=\cos (2\pi ft)\) in Fig. 1 is sampled uniformly with 3 sampling intervals within each signal period \(T\). Therefore, the sampling interval \(T_s=T/3\) and the sampling rate \(f_s=3f\). Another way see that \(f_s=3f\) is to notice that there are three samples in every signal period \(T\).

    To express the samples of the analog signal \(v(t)\), we use the notation \(v[n]\) (with square brackets), where integer values of \(n\) index the samples. Typically, the \(n = 0\) sample is taken from the \(t=0\) time point of the analog signal. Consequently, the \(n=1\) sample must come from the \(t=T_s\) time point, exactly one sampling interval later; and so on. Therefore, the sequence of samples can be written as \(v[0] = v(0), v[1] = v[T_s], v[2] = v(2T_s)\),...

    \(v[n] = v(nT_s) \ \ \ \ \ \ \ \ \ \ \ \ \text{for integer } n .........................................1\)

    In the example of Fig. 4, \(v(t) = \cos (2 \pi ft)\) is sampled with sampling interval \(T_s = T/3\)

    to produce the following \(v[n]\).

    \(\begin{array} {rclcl} {v[n]} & = & {\cos (2 \pi fn/T_s)} & \ \ \ \ \ \ \ & {\text{by substituting } t = nT_s .................................2} \\ {} & = & {\cos (2 \pi fn T/3)} & \ \ \ \ \ \ \ & {\text{since } T_s = T/3 .............................3} \\ {} & = & {\cos (2 \pi n/3)} & \ \ \ \ \ \ \ & {\text{since } T = 1/f .............................4} \end{array}\)

    This expression for \(v[n]\) evaluates to the sample values depicted in Fig. 4 as shown below.

    \(v[0] = \cos (0) = 1\)

    \(v[1] = \cos (2\pi 3) = -0.5\)

    \(v[2] = \cos (4 \pi 3) = -0.5\)

    \(v[3] = \cos (2\pi) = 1\)

    Fig. 5: Samples. The samples from Fig. 4 are shown as the sequence \(v[n]\) indexed by integer values of \(n\).


    Since a discrete signal has discrete points in time but still has continuous values in amplitude, the amplitude of the signal must be discretized in order to store it in digital format. The values of the amplitude must be rounded off to discrete values. If the vertical axis is divided into small windows of amplitudes, then every value that lies within that window will be rounded off (or quantized) to the same value.

    For example, consider a waveform with window sizes of 0.5 volts starting at –4 volts and ending at +4 volts. At a discrete point in time, any amplitude between 4.0 volts and 3.5 volts will be recorded as 3.75 volts. In this example the center of each 0.5-volt window (or quantization region) was chosen to be the quantization voltage for that region.

    In this example the dynamic range of the signal is 8 volts. Since each quantization region is 0.5 volts there are 16 quantization regions included in the dynamic range. It is important that there are 16 quantization regions in the dynamic range. Since a binary number will represent the value of the amplitude, it is important that the number of quantization regions is a power of two. In this example, 4 bits will be required to represent each of the 16 possible values in the signal’s amplitude.

    A sequence of samples like v[n] in Fig. 5 is not a digital signal because the sample values can potentially take on a continuous range of values. In order to complete analog to digital conversion, each sample value is mapped to a discrete level (represented by a sequence of bits) in a process called quantization. In a B-bit quantizer, each quantization level is represented with B bits, so that the number of levels equals 2B

    Fig. 6: 3-bit quantization. Overlaid on the samples \(v[n]\) from Fig. 5 is a 3-bit quantizer with 8 uniformly spaced quantization levels. The quantizer approximates each sample value in \(v[n]\) to its nearest level value (shown on the left), producing the quantized sequence \(vQ[n]\). Ultimately the sequence \(vQ[n]\) can be written as a sequence of bits using the 3-bit representations shown on the right.

    Observe that quantization introduces a quantization error between the samples and their quantized versions given by \(e[n]=v[n]−vQ[n]\). If a sample lies between quantization levels, the maximum absolute quantization error \(|e[n]|\) is half of the spacing between those levels. For the quantizer in Fig. 6, the maximum error between levels is 0.15 since the spacing is uniformly 0.3. Note, however, that if the sample overshoots the highest level or undershoots the lowest level by more than 0.15, the absolute quantization error will be that difference larger than 0.15.

    The table below completes the quantization example in Fig. 6 for \(n=0, 1, 2, 3\). The 3-bit representations in the final row can be concatenated finally into the digital signal 110001001110.

    Table 1: Quantization example.

    Sequence \(n = 0\) \(n = 1\) \(n = 2\) \(n = 3\)
    Samples \(v[n]\) 1 -0.5 -0.5 1
    Quantized samples \(vQ[n]\) 0.9 -0.6 -0.6 0.9
    0.1 0.1 0.1 0.1
    3-bit representations 110 1 1 110


    This section has made the learners learn how analog (continuous) data can be digitized


    1. What is the difference between analogue and digital data?

    Analogue data is continuous, allowing for an infinite number of possible values. Digital data is discrete, allowing for a finite set of values

    2. Why is it difficult to save analogue sound waves in a digital format?

    Analogue is continuous data, converting continuous data to discrete values may lose some of the accuracy

    3. Differentiate between anlog and digital data

    Analog refers to circuits in which quantities such as voltage or current vary at a continuous rate. When you turn the dial of a potentiometer, for example, you change the resistance by a continuously varying rate. The resistance of the potentiometer can be any value between the minimum and maximum allowed by the pot. In digital electronics, quantities are counted rather than measured. There’s an important distinction between counting and measuring. When you count something, you get an exact result. When you measure something, you get an approximate result.

    This page titled 5.1: Representation of digital and analog values - Sampling and Quantization is shared under a CC BY-SA license and was authored, remixed, and/or curated by Harrison Njoroge (African Virtual University) .

    • Was this article helpful?