Signals to learning / 3. From time to samples

Lesson 11 of 40 · Beginner · About 20 minutes

Quantisation and clipping

What changes when sample values have a finite alphabet?

You will be able to

  • Distinguish time sampling from amplitude quantisation.
  • Calculate levels and recognise irreversible clipping.

A second discretisation

Sampling chooses measurement times; quantisation chooses representable values. An ideal b-bit scalar quantiser has 2ᵇ codes. This lab uses evenly spaced levels including −1 and +1, rounding to the nearest level. Hardware converters may use different endpoint conventions, offset and non-ideal behaviour.

Error is not always random

Rounding creates error between the input and output. It may be structured and correlated with the signal, especially at low amplitude or low precision. Clipping is different: values outside the range saturate, losing peak information. Extra sample rate does not fix an overloaded amplitude range. Dither can decorrelate certain quantisation errors at the cost of added noise.

L = 2ᵇ; lab level spacing Δ = 2/(L−1) across [−1,1]

Worked example

With 2 bits, this lab has levels −1, −1/3, +1/3, +1. An input of 1.4 clips to 1. In the non-clipped region, nearest-level rounding error is at most Δ/2.

A common trap

All b-bit systems do not have this exact endpoint formula; state the quantiser convention before calculating error.

Predict, then experiment

At 2 bits, is zero one of the represented levels in this lab? Before touching the controls, say or write your prediction.

Try it yourself

A finite amplitude alphabet

How do rounding and clipping differ?

64 samples of a 3 Hz sine. Solid is input; dashed with circles is quantised. Equally spaced endpoint-inclusive levels across [−1,1]; nearest-level rounding and clipping.

Can you make it happen?

Use at least 64 amplitude levels without clipping any input samples.

Predict a setting before you try it. This optional challenge checks the current parameters, not lesson completion.

A hint

The level count is 2 raised to the number of bits. Clipping is controlled by signal amplitude, independently of bit count.

One solution & why it works

Bits 6 and amplitude 1 give 64 levels and no out-of-range samples. More bits also work; amplitude above 1 clips this sampled sine.

Your experiment

Compare 2, 4 and 8 bits at amplitude 0.8. Increase amplitude to 1.5 and observe clipping even at 8 bits. Explain the difference between fine rounding and saturation.

Change one parameter at a time. Compare what you observed with your prediction and record an explanation in your notes.

Check your understanding

Try from memory first. Hints and feedback are part of learning, not a penalty. These checks are for self-study, not a graded qualification.

1. Which change specifically increases amplitude resolution?
Give me a hint

Count the representable levels.

2. How many codes can 6 bits represent?

Accepted absolute tolerance: ±0.001 levels.

Give me a hint

Raise two to the bit count.

Reference answers (after your attempt)
  1. More bits per sample — Correct: more representable values.
  2. 64levels — 2⁶=64.

Apply it: Write a quantiser contract

Use paper, your notes, or a local notebook/editor. Code examples are Python 3 starting points to run yourself; this page does not execute code or automatically assess the practical task.

  1. Specify range, bits, endpoint convention and rounding.
  2. Calculate Δ for the 3-bit lab quantiser.
  3. State what happens to an input of −1.2.
Reference solution & review criteria

Eight levels across [−1,1] have spacing 2/7. Round to nearest; clip −1.2 to −1. Record this convention rather than assuming it matches every ADC.

Your notebook

Notes and progress stay in this browser. They are not sent to the server; ordinary web-server request logs still operate. Export a backup from the course page.

Review list

Completion requires both correct checks and your practical-task acknowledgement.

Go deeper

Sources support further study; the worked examples and questions here are original. Browser experiments are small, disclosed models—not evidence of production-model quality or hardware performance.