Algorithm Search⌘K

Techniquecore

Adaptive equalization

Also called decision-directed equalization.

Adjusts the equalizer taps with an adaptive filter such as LMS, first from a training sequence and then from the decided symbols, so the equalizer learns and tracks an unknown channel.

Adaptive equalization is the technique of learning the taps of an equalizer from the received signal, in place of computing them from a known channel. An adaptive filter, usually the LMS algorithm, adjusts the taps at every symbol to make the equalizer output match a target symbol. During a training sequence the target is the known symbol. After it, the target is the receiver's own decision, so the equalizer keeps tracking slow changes of the channel with no extra overhead. The taps move toward the MMSE equalizer taps on average, and the same template adapts a decision feedback equalizer or a fractionally spaced equalizer. This page differs from Kalman channel tracking: here the filter adapts the equalizer taps directly, with a fixed step and no model of how the channel moves; there a Kalman filter estimates the channel itself, using a model of its motion to set the gain at each step.

In plain words

A receiver does not know the echoes of the channel in advance, and the echoes can change slowly. So the receiver starts with a filter that does nothing and improves it a little at each symbol. At the start, the sender transmits symbols that the receiver already knows. The receiver compares its filter output with the known symbol and nudges the filter in the direction that makes the difference smaller. After the known part ends, the receiver uses its own decisions as the right answers. This works as long as most decisions are correct. If too many are wrong, the filter learns the wrong thing and the receiver must start again with known symbols.

When it applies

  • The channel is unknown or changes slowly compared with the time the filter needs to adapt.
  • A training sequence is available at the start, or the eye is already open, so that most decisions are correct.
  • The equalizer structure is fixed: a linear filter, a decision feedback filter or a fractionally spaced filter, whose output is linear in the taps.
  • The cost of a closed form design, such as a matrix solve for the MMSE taps, is too high per symbol, or the channel statistics needed for it are unknown.

It does not apply as stated when there is no training and the eye is closed; then a blind start such as the constant modulus algorithm must open the eye first, see blind equalization.

The template

The input is the received samples yy, the training symbols a[0],…,a[T−1]a[0], \ldots, a[T-1], the number of taps NN, the decision delay dd, the step size μ\mu and the constellation. The output z[k]=∑ici y[k−i]z[k] = \sum_i c_i\, y[k-i] estimates a[k−d]a[k-d]. The holes are the adaptive rule (here LMS) and the decision rule (here the nearest constellation point).

  1. ADAPTIVE-EQUALIZER(y, a[0..T-1], N, d, μ, constellation)
  2. 1c ← (0, ..., 0)
  3. 2for k ← N - 1 to K - 1 do
  4. 3u ← (y[k], y[k-1], ..., y[k-N+1])
  5. 4z[k] ← Σ_i c[i] u[i]
  6. 5if k - d < T then target ← a[k - d] ▷ training mode
  7. 6else target ← the constellation point nearest to z[k] ▷ decision mode
  8. 7e ← z[k] - target
  9. 8c[i] ← c[i] - μ e conj(u[i]) for all i ▷ LMS
  10. 9return c, z

Lines L3 and L4 are the equalizer. Lines L5 and L6 choose the target: a known symbol while training lasts, the decision after. Lines L7 and L8 are one LMS step on the squared error ∣z−target∣2|z - \text{target}|^2.

Where it converges. In training mode, the targets are the true symbols, and line L8 is a stochastic gradient step on J(c)=E∣z[k]−a[k−d]∣2J(c) = E|z[k] - a[k-d]|^2. The minimizer is the Wiener solution c∗=R−1p‾c^* = \overline{R^{-1} p} with R=E[uuH]R = E[u u^H] and p=E[u a[k−d]‾]p = E[u\, \overline{a[k-d]}], which is the MMSE equalizer for the delay dd. This is a closed form. Under the usual independence assumption of LMS theory, the mean taps converge to c∗c^* if 0<μ<2/λmax⁡(R)0 < \mu < 2/\lambda_{\max}(R), and the slowest mode decays like (1−μλmin⁡)k(1 - \mu \lambda_{\min})^k. This is a theorem under that assumption, not for the real dependent regressors. The excess error above J(c∗)J(c^*) grows with μ\mu.

Decision mode. If every decision is correct, line L6 gives the same target as training, and the analysis holds. Wrong decisions bias the update. There is no general guarantee: the mode works when the decision error rate is low, which is a heuristic rule backed by practice.

Cost. Lines L3 to L8 cost O(N)O(N) per symbol, plus the decision in line L6, which is O(M)O(M) for MM points, or O(1)O(1) per axis for square QAM. The memory is O(N)O(N).

Example. One tap, y=(0.9,1.2)y = (0.9, 1.2), training symbols (1,1)(1, 1), d=0d = 0 and μ=0.1\mu = 0.1. At k=0k = 0: z=0z = 0, e=−1e = -1, c=0+0.1×1×0.9=0.09c = 0 + 0.1 \times 1 \times 0.9 = 0.09. At k=1k = 1: z=0.09×1.2=0.108z = 0.09 \times 1.2 = 0.108, e=−0.892e = -0.892, c=0.09+0.1×0.892×1.2=0.197c = 0.09 + 0.1 \times 0.892 \times 1.2 = 0.197.

A larger run: QPSK through h=(1,0.5)h = (1, 0.5) with N0=0.01N_0 = 0.01, N=11N = 11, d=5d = 5, μ=0.01\mu = 0.01 and seed 1. The Wiener MSE is 0.01320.0132, and the Wiener taps from tap 5 on are 0.983,−0.485,0.238,−0.1160.983, -0.485, 0.238, -0.116, close to the inverse of the channel. The MSE of the LMS taps after KK training symbols is a measurement:

training symbols 100 200 500 1000 2000 6000
MSE of the taps 0.208 0.075 0.024 0.0139 0.0136 0.0138

With 1000 training symbols and then the decision mode on 11000 more (seed 2), there are no decision errors and the MSE stays within 10 percent of the Wiener value. On the Proakis B channel (0.407,0.815,0.407)(0.407, 0.815, 0.407), which has a deep spectral notch, 6000 training symbols give an MSE of 0.1960.196 against the Wiener 0.1900.190, but taps that differ from the Wiener taps by up to 0.290.29: the slow modes of a large eigenvalue spread have not converged, although they hardly change the MSE. The tests in the code folder check these runs.

Classic examples

  • Voiceband modems. Lucky (1965) adjusted the taps of a transversal equalizer automatically from the data, and adaptive equalizers made high-speed telephone modems possible. Modems sent a short training sequence at the start of a call and then adapted from decisions.
  • Adaptive DFE. The feedforward and feedback filters of a decision feedback equalizer are both linear in their taps, so one LMS step on the stacked tap vector adapts both. The past decisions are already available for the feedback filter.
  • Fractionally spaced adaptive equalizers. A fractionally spaced equalizer adapted by LMS also learns the sampling phase, which made it the usual choice in later modems.
  • Blind start, then decisions. In cable and broadcast receivers, a blind algorithm such as CMA or the Sato algorithm opens the eye, and the receiver then switches to the decision mode of this template.

Variations

  • RLS in place of LMS. The RLS algorithm converges in about 2N2N symbols by a common rule of thumb, almost independently of the eigenvalue spread, at a cost of O(N2)O(N^2) per symbol. It suits short training sequences and channels with deep notches.
  • Normalized LMS. Divide the step by ∥u∥2\|u\|^2, which makes the convergence less sensitive to the signal level.
  • Sign algorithms. Use the sign of the error or of the regressor in line L8. This saves multiplications in hardware, at the cost of slower convergence.
  • Channel tracking in place of tap adaptation. Estimate the channel with a Kalman filter or with RLS, and design the equalizer from the estimate. This uses a model of how the channel moves.
  • Periodic training. Insert training symbols at intervals, as in burst systems, so that the equalizer can recover after error bursts.

Pitfalls

  • A step that is too large in line L8. If μ≥2/λmax⁡(R)\mu \ge 2/\lambda_{\max}(R), the mean taps diverge. Even below that, a large μ\mu gives a large excess error. A normalized step or a step that shrinks after training helps.
  • A step that is too small. The slowest mode needs about 1/(μλmin⁡)1/(\mu \lambda_{\min}) symbols. On a channel with a deep notch, the eigenvalue spread is large and LMS converges slowly, as the Proakis B example shows.
  • Switching to line L6 too early. If the decision error rate is high, the decisions pull the taps the wrong way, and errors feed more errors. Switch only after the training has opened the eye.
  • A delay that does not fit. The delay dd must give the equalizer room to cancel both the precursors and the postcursors. A delay at the edge of the filter, such as d=0d = 0 on a nonminimum-phase channel, leaves a large MSE whatever the step.
  • Fast fading. If the channel changes faster than LMS can track, the taps lag behind. A tracker with a model of the channel motion, such as the Kalman filter, does better.

Code

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

adaptive_equalization.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/adaptive-equalization/. The authors are listed in prov/FM2HQC.jsonl.

"""An adaptive linear equalizer with a training mode and a decision mode.

The equalizer is an FIR filter c of N taps with output
z[k] = sum_i c[i] y[k-i], which estimates the symbol a[k-d] for a fixed
delay d. While known training symbols remain, the target is the training
symbol. After that, the target is the constellation point nearest to z.
The update is the LMS step c <- c - mu (z - target) conj(u).

wiener_taps gives the MMSE taps for a known channel, the point that LMS in
training mode converges to on average.
"""

import cbb


def nearest(z: complex, points: list[complex]) -> complex:
    """The constellation point closest to z."""
    return min(points, key=lambda p: abs(z - p))


def adaptive_equalize(
    y: list[complex], train: list[complex], n: int, delay: int, mu: float, points: list[complex]
) -> tuple[list[complex], list[complex], list[complex]]:
    """Run the equalizer over y.

    train[t] is the known symbol a[t] for t < len(train). Returns the final
    taps, the outputs z[k] and the targets used, for k = N-1, ..., len(y)-1;
    output k estimates a[k - delay].
    """
    if n < 1 or not 0 <= delay <= n - 1 or mu <= 0 or not points:
        raise ValueError("need N >= 1, 0 <= delay <= N - 1, mu > 0 and a constellation")
    c = [0j] * n  # @line L1
    outs, targets = [], []
    for k in range(n - 1, len(y)):  # @line L2
        u = [complex(y[k - i]) for i in range(n)]  # @line L3
        z = sum(ci * ui for ci, ui in zip(c, u))  # @line L4
        if k - delay < len(train):  # @line L5
            target = complex(train[k - delay])  # @line L5
        else:
            target = nearest(z, points)  # @line L6
        e = z - target  # @line L7
        c = [ci - mu * e * ui.conjugate() for ci, ui in zip(c, u)]  # @line L8
        outs.append(z)
        targets.append(target)
    return c, outs, targets  # @line L9


def wiener_taps(h: list[complex], n: int, delay: int, n0: float, es: float = 1.0) -> list[complex]:
    """The MMSE taps c that minimize E|sum_i c[i] y[k-i] - a[k-delay]|^2 for a known channel.

    With u = H a + w, H[i][m] = h[m - i], R = es H H^H + n0 I and
    p = es H[:, delay], the optimum is c = conj(R^-1 p).
    """
    m = n + len(h) - 1
    hm = [[complex(h[col - i]) if 0 <= col - i < len(h) else 0j for col in range(m)] for i in range(n)]
    r = cbb.add(cbb.scale(es, cbb.matmul(hm, cbb.herm(hm))), cbb.scale(n0, cbb.eye(n)))
    p = [es * hm[i][delay] for i in range(n)]
    return [v.conjugate() for v in cbb.solve(r, p)]


def mse(c: list[complex], h: list[complex], delay: int, n0: float, es: float = 1.0) -> float:
    """The mean square error E|z - a[k-delay]|^2 of taps c on a known channel."""
    g = cbb.conv(c, h)
    isi = sum(abs(v) ** 2 for i, v in enumerate(g) if i != delay)
    cursor = g[delay] if delay < len(g) else 0j
    return es * (isi + abs(cursor - 1) ** 2) + n0 * cbb.norm2(c)
cbb.py 315 lines
# SPDX-License-Identifier: MIT
# Shared helper of the communications pages of https://algorithm.tamnd.com/. The authors are listed in prov/.

"""Complex baseband tools for the communications pages.

Vectors are lists of complex numbers. Matrices are lists of rows. The
functions here are plain building blocks: small linear algebra, convolution,
the DFT as a direct sum, the Gaussian Q function, dB conversion, complex
Gaussian noise and the Wilson score interval. No page algorithm (equalizer,
estimator, synchronizer, detector, precoder, demapper or power allocation)
lives in this file.

Conventions (prompts of the communications area):
- dft is X[k] = sum_n x[n] e^(-j 2 pi k n / N) with no factor; idft has 1/N.
- udft and uidft are the unitary pair, with 1/sqrt(N) on both sides.
- qfunc(x) = 0.5 erfc(x / sqrt(2)); it never computes 1 - Phi(x).
- cn(rng, var) draws CN(0, var): real and imaginary parts are independent
  with variance var / 2 each, so E|w|^2 = var.
"""

import cmath
import math
import random


# ---------------------------------------------------------------- vectors and matrices


def zeros(rows: int, cols: int | None = None) -> list:
    """A zero vector of length rows, or a rows by cols zero matrix."""
    if cols is None:
        return [0j] * rows
    return [[0j] * cols for _ in range(rows)]


def eye(n: int) -> list[list[complex]]:
    """The n by n identity matrix."""
    return [[1 + 0j if i == k else 0j for k in range(n)] for i in range(n)]


def add(a: list, b: list) -> list:
    """Elementwise a + b for two vectors or two matrices of the same shape."""
    if len(a) != len(b):
        raise ValueError("shapes differ")
    if a and isinstance(a[0], list):
        return [add(r, s) for r, s in zip(a, b)]
    return [x + y for x, y in zip(a, b)]


def sub(a: list, b: list) -> list:
    """Elementwise a - b for two vectors or two matrices of the same shape."""
    if len(a) != len(b):
        raise ValueError("shapes differ")
    if a and isinstance(a[0], list):
        return [sub(r, s) for r, s in zip(a, b)]
    return [x - y for x, y in zip(a, b)]


def scale(c: complex, a: list) -> list:
    """The scalar c times a vector or a matrix."""
    if a and isinstance(a[0], list):
        return [scale(c, r) for r in a]
    return [c * x for x in a]


def matmul(a: list[list[complex]], b: list[list[complex]]) -> list[list[complex]]:
    """The matrix product a b."""
    if not a or not b or len(a[0]) != len(b):
        raise ValueError("inner dimensions differ")
    cols = list(zip(*b))
    return [[sum(x * y for x, y in zip(row, col)) for col in cols] for row in a]


def matvec(a: list[list[complex]], x: list[complex]) -> list[complex]:
    """The matrix times vector product a x."""
    if a and len(a[0]) != len(x):
        raise ValueError("inner dimensions differ")
    return [sum(p * q for p, q in zip(row, x)) for row in a]


def herm(a: list) -> list:
    """The conjugate transpose of a matrix. A vector gives its conjugate."""
    if a and isinstance(a[0], list):
        return [[complex(a[i][k]).conjugate() for i in range(len(a))] for k in range(len(a[0]))]
    return [complex(x).conjugate() for x in a]


def dot(x: list[complex], y: list[complex]) -> complex:
    """The inner product x^H y = sum of conj(x_i) y_i."""
    if len(x) != len(y):
        raise ValueError("lengths differ")
    return sum(complex(p).conjugate() * q for p, q in zip(x, y))


def norm2(x: list) -> float:
    """The squared Euclidean norm sum |x_i|^2 (squared Frobenius norm for a matrix)."""
    if x and isinstance(x[0], list):
        return sum(norm2(r) for r in x)
    return sum(abs(v) ** 2 for v in x)


# ---------------------------------------------------------------- linear systems


def _lu(a: list[list[complex]]) -> tuple[list[list[complex]], list[int], int]:
    """LU factorization with partial pivoting. Returns (lu, perm, sign)."""
    n = len(a)
    if any(len(r) != n for r in a):
        raise ValueError("matrix is not square")
    m = [[complex(v) for v in r] for r in a]
    perm = list(range(n))
    sign = 1
    for k in range(n):
        p = max(range(k, n), key=lambda i: abs(m[i][k]))
        if abs(m[p][k]) == 0.0:
            raise ValueError("matrix is singular")
        if p != k:
            m[k], m[p] = m[p], m[k]
            perm[k], perm[p] = perm[p], perm[k]
            sign = -sign
        for i in range(k + 1, n):
            f = m[i][k] / m[k][k]
            m[i][k] = f
            if f != 0:
                rk, ri = m[k], m[i]
                for c in range(k + 1, n):
                    ri[c] -= f * rk[c]
    return m, perm, sign


def _lu_solve(lu: list[list[complex]], perm: list[int], b: list[complex]) -> list[complex]:
    n = len(lu)
    y = [complex(b[perm[i]]) for i in range(n)]
    for i in range(n):
        for c in range(i):
            y[i] -= lu[i][c] * y[c]
    for i in range(n - 1, -1, -1):
        for c in range(i + 1, n):
            y[i] -= lu[i][c] * y[c]
        y[i] /= lu[i][i]
    return y


def solve(a: list[list[complex]], b: list) -> list:
    """Solve a x = b by Gaussian elimination with partial pivoting.

    b is a vector, or a matrix whose columns are right-hand sides.
    Raises ValueError if a is singular.
    """
    lu, perm, _ = _lu(a)
    if b and isinstance(b[0], list):
        cols = [list(c) for c in zip(*b)]
        xs = [_lu_solve(lu, perm, c) for c in cols]
        return [list(r) for r in zip(*xs)]
    if len(b) != len(a):
        raise ValueError("lengths differ")
    return _lu_solve(lu, perm, b)


def inv(a: list[list[complex]]) -> list[list[complex]]:
    """The inverse of a square matrix."""
    return solve(a, eye(len(a)))


def det(a: list[list[complex]]) -> complex:
    """The determinant of a square matrix (0 for a singular matrix)."""
    try:
        lu, _, sign = _lu(a)
    except ValueError as e:
        if "singular" in str(e):
            return 0j
        raise
    d = complex(sign)
    for i in range(len(lu)):
        d *= lu[i][i]
    return d


def cholesky(a: list[list[complex]]) -> list[list[complex]]:
    """The lower triangular L with a = L L^H, for a Hermitian positive definite a.

    Raises ValueError if a is not positive definite (to rounding).
    """
    n = len(a)
    low = zeros(n, n)
    for i in range(n):
        for k in range(i + 1):
            s = complex(a[i][k]) - sum(low[i][c] * low[k][c].conjugate() for c in range(k))
            if i == k:
                if s.real <= 0.0:
                    raise ValueError("matrix is not positive definite")
                low[i][i] = complex(math.sqrt(s.real))
            else:
                low[i][k] = s / low[k][k].real
    return low


# ---------------------------------------------------------------- convolution and the DFT


def conv(a: list[complex], b: list[complex]) -> list[complex]:
    """Linear convolution, of length len(a) + len(b) - 1."""
    if not a or not b:
        return []
    out = [0j] * (len(a) + len(b) - 1)
    for i, x in enumerate(a):
        for k, y in enumerate(b):
            out[i + k] += x * y
    return out


def cconv(a: list[complex], b: list[complex], n: int | None = None) -> list[complex]:
    """Circular convolution of length n (default: the longer length).

    Both inputs are padded with zeros to length n, or must not be longer than n.
    """
    if n is None:
        n = max(len(a), len(b))
    if len(a) > n or len(b) > n:
        raise ValueError("input longer than n")
    out = [0j] * n
    for i, x in enumerate(a):
        for k, y in enumerate(b):
            out[(i + k) % n] += x * y
    return out


def _twiddles(n: int, sign: int) -> list[complex]:
    return [cmath.exp(sign * 2j * math.pi * t / n) for t in range(n)]


def dft(x: list[complex]) -> list[complex]:
    """X[k] = sum over n of x[n] e^(-j 2 pi k n / N), as a direct O(N^2) sum."""
    n = len(x)
    w = _twiddles(n, -1)
    return [sum(x[t] * w[(k * t) % n] for t in range(n)) for k in range(n)]


def idft(xf: list[complex]) -> list[complex]:
    """x[n] = (1/N) sum over k of X[k] e^(j 2 pi k n / N), the inverse of dft."""
    n = len(xf)
    w = _twiddles(n, 1)
    return [sum(xf[k] * w[(k * t) % n] for k in range(n)) / n for t in range(n)]


def udft(x: list[complex]) -> list[complex]:
    """The unitary DFT: dft(x) / sqrt(N)."""
    s = 1.0 / math.sqrt(len(x)) if x else 1.0
    return [v * s for v in dft(x)]


def uidft(xf: list[complex]) -> list[complex]:
    """The unitary inverse DFT: sqrt(N) idft(X), the inverse of udft."""
    s = math.sqrt(len(xf)) if xf else 1.0
    return [v * s for v in idft(xf)]


# ---------------------------------------------------------------- Q function and dB


def qfunc(x: float) -> float:
    """Q(x) = P(Z > x) for a standard normal Z, computed as 0.5 erfc(x / sqrt(2))."""
    return 0.5 * math.erfc(x / math.sqrt(2.0))


def qinv(p: float) -> float:
    """The x with Q(x) = p, for 0 < p < 1, by bisection on Q (which decreases)."""
    if not 0.0 < p < 1.0:
        raise ValueError("p must be in (0, 1)")
    lo, hi = -40.0, 40.0
    for _ in range(200):
        mid = 0.5 * (lo + hi)
        if qfunc(mid) > p:
            lo = mid
        else:
            hi = mid
        if hi - lo <= 1e-15 * max(1.0, abs(mid)):
            break
    return 0.5 * (lo + hi)


def db(x: float) -> float:
    """10 log10(x), for a ratio of powers or energies."""
    return 10.0 * math.log10(x)


def undb(d: float) -> float:
    """10^(d / 10), the inverse of db."""
    return 10.0 ** (d / 10.0)


# ---------------------------------------------------------------- noise and statistics


def cn(rng: random.Random, var: float) -> complex:
    """One sample of CN(0, var): independent real and imaginary parts of variance var / 2."""
    s = math.sqrt(var / 2.0)
    return complex(rng.gauss(0.0, s), rng.gauss(0.0, s))


def awgn(rng: random.Random, x: list[complex], n0: float) -> list[complex]:
    """x plus independent CN(0, n0) noise on each sample."""
    return [v + cn(rng, n0) for v in x]


def wilson(k: int, n: int, z: float = 3.29) -> tuple[float, float]:
    """The Wilson score interval for k successes in n trials (z = 3.29 is about 0.999 two-sided)."""
    if n <= 0 or not 0 <= k <= n:
        raise ValueError("need 0 <= k <= n and n > 0")
    p = k / n
    z2 = z * z
    den = 1.0 + z2 / n
    mid = (p + z2 / (2 * n)) / den
    half = z * math.sqrt(p * (1 - p) / n + z2 / (4 * n * n)) / den
    return max(0.0, mid - half), min(1.0, mid + half)
test_adaptive_equalization.py 75 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/adaptive-equalization/. The authors are listed in prov/FM2HQC.jsonl.

import math
import random

import pytest

import cbb
from adaptive_equalization import adaptive_equalize, mse, nearest, wiener_taps

QPSK = [complex(a, b) / math.sqrt(2) for a in (-1, 1) for b in (-1, 1)]
PROAKIS_B = [0.407, 0.815, 0.407]


def run(h, n, delay, mu, k, n0, seed, n_train):
    rng = random.Random(seed)
    x = [rng.choice(QPSK) for _ in range(k)]
    y = cbb.awgn(rng, cbb.conv(x, h)[:k], n0)
    c, z, targets = adaptive_equalize(y, x[:n_train], n, delay, mu, QPSK)
    return x, c, z, targets


def test_wiener_taps_one_tap_closed_form() -> None:
    h = [0.8 - 0.3j, 0.4j, -0.2]
    n0 = 0.05
    c = wiener_taps(h, 1, 0, n0)
    want = h[0].conjugate() / (cbb.norm2(h) + n0)
    assert abs(c[0] - want) < 1e-12


def test_wiener_taps_are_a_minimum_of_the_mse() -> None:
    h = [1, 0.5]
    n0 = 0.01
    w = wiener_taps(h, 7, 3, n0)
    j0 = mse(w, h, 3, n0)
    rng = random.Random(7)
    for _ in range(20):
        dv = [complex(rng.gauss(0, 1), rng.gauss(0, 1)) * 1e-3 for _ in w]
        assert mse([a + b for a, b in zip(w, dv)], h, 3, n0) > j0


def test_training_mode_converges_to_the_wiener_taps() -> None:
    h, n, d, n0 = [1, 0.5], 11, 5, 0.01
    x, c, z, targets = run(h, n, d, 0.01, 6000, n0, 1, 6000)
    w = wiener_taps(h, n, d, n0)
    assert max(abs(a - b) for a, b in zip(c, w)) < 0.05
    assert mse(c, h, d, n0) < 1.1 * mse(w, h, d, n0)
    assert all(t == x[k + n - 1 - d] for k, t in enumerate(targets))


def test_decision_mode_keeps_the_taps_after_training() -> None:
    h, n, d, n0 = [1, 0.5], 11, 5, 0.01
    x, c, z, targets = run(h, n, d, 0.01, 12000, n0, 2, 1000)
    errors = sum(nearest(z[t], QPSK) != x[t + n - 1 - d] for t in range(1000, len(z)))
    assert errors == 0
    assert mse(c, h, d, n0) < 1.1 * mse(wiener_taps(h, n, d, n0), h, d, n0)


def test_slow_modes_on_a_channel_with_a_deep_notch() -> None:
    # Proakis B: the MSE is near the Wiener value, but the taps are not, because of the eigenvalue spread
    n, d, n0 = 11, 6, 0.01
    x, c, z, targets = run(PROAKIS_B, n, d, 0.01, 6000, n0, 1, 6000)
    w = wiener_taps(PROAKIS_B, n, d, n0)
    assert mse(c, PROAKIS_B, d, n0) < 1.1 * mse(w, PROAKIS_B, d, n0)
    assert max(abs(a - b) for a, b in zip(c, w)) > 0.1


def test_bad_input() -> None:
    with pytest.raises(ValueError):
        adaptive_equalize([1, 2], [], 0, 0, 0.01, QPSK)
    with pytest.raises(ValueError):
        adaptive_equalize([1, 2], [], 2, 2, 0.01, QPSK)
    with pytest.raises(ValueError):
        adaptive_equalize([1, 2], [], 2, 0, 0.0, QPSK)

Exercises

  1. For a one-tap equalizer on the channel y[k]=h a[k]+w[k]y[k] = h\, a[k] + w[k], with E∣a∣2=1E|a|^2 = 1 and noise power N0N_0, find the Wiener tap and the largest step for which the mean of the LMS tap converges.
  2. Show that if every decision of line L6 is correct, the decision mode gives exactly the same tap sequence as training mode with the same symbols.
  3. Write the LMS update for a DFE with NfN_f feedforward and NbN_b feedback taps. Which regressor does the feedback part use?
  4. Run the code on Proakis B with 6000 training symbols and μ=0.01\mu = 0.01, then with RLS. Compare the number of symbols each needs to reach an MSE within 10 percent of the Wiener value.

References

  1. R. W. Lucky, Automatic equalization for digital communication, Bell System Technical Journal 44(4), 1965, pages 547 to 588, the automatic adjustment of a transversal equalizer from the received data
  2. Shahid U. H. Qureshi, Adaptive equalization, Proceedings of the IEEE 73(9), 1985, pages 1349 to 1387, the training and decision-directed modes, LMS and RLS adaptation, and the tracking of slow channel changes
  3. John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Chapter 10 (adaptive equalization)
  4. John R. Barry, Edward A. Lee and David G. Messerschmitt, Digital Communication, third edition, Kluwer Academic Publishers, 2004, the chapter on adaptive equalization

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW3 standard
  • five exercises