Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Compute a block's per-symbol distortion

Use when: you have a source block x^n and its reconstruction \hat x^n, and need the total or per-symbol distortion under Hamming or squared-error distortion

Goal: the per-symbol distortion d(x^n,\hat x^n)=\frac1n\sum d(x_i,\hat x_i), using the measure that matches the alphabet

Taught in Distortion measures (Hamming, squared error)

  1. 1

    Check whether the source's values are discrete, where wrong is just wrong with no notion of "how far," or continuous, where the size of a miss varies.

    Example

    A bit-string reconstruction calls for Hamming distortion; a sensor reading calls for squared-error distortion.

    • discrete alphabet — use Hamming distortion, d(x,\hat x)=0 if x=\hat x and 1 otherwise.
    • continuous alphabet — use squared-error distortion, d(x,\hat x)=(x-\hat x)^2.

    Why: neither measure is universally correct; the choice is part of the problem's own modeling decision, made before any number gets computed.

  2. 2

    Apply the formula chosen in Step 1 to each pair x_i,\hat x_i in the block.

    Example

    For x=1001101 and \hat x=1101100: positions 2 and 5 disagree (each costing 1 under Hamming), the rest agree (costing 0).

    Why: the block distortion is built entirely out of these individual per-position costs.

  3. 3

    Average the costs from Step 2 over the whole block.

    Example

    Two disagreements out of 7 positions: \dfrac{2}{7}\approx0.286.

    Why: dividing by n turns a raw total into a per-symbol rate, which is what makes distortion comparable across blocks of different lengths.

  4. 4

    Match the interpretation to whichever measure was chosen back in Step 1.

    Example

    For a sensor reading x=4.5 reproduced as \hat x=4.8: d(4.5,4.8)=(4.5-4.8)^2=0.09, in squared units, not the same units as the original reading.

    • Hamming distortion was used — read the result as a fraction of positions wrong, a probability once averaged over the source's own randomness.
    • squared-error distortion was used — read the result in squared units of the original quantity, not the original units themselves.

    Why: the two measures aren't comparable to each other or interchangeable in meaning, even when the raw numbers happen to look similar in size.

Common mistakes

  • Applying squared-error distortion to a discrete alphabet where "how far wrong" has no meaning, such as a flipped bit.
  • Forgetting to divide by n, reporting a raw total instead of the per-symbol rate the theory is built on.
  • Reporting a squared-error result as if it were in the original units, instead of squared units.
  • Mixing the two measures within the same block instead of picking one and applying it consistently to every symbol.