Algorithm Search⌘K

Techniqueadvanced

Per-survivor processing

Also called per-survivor estimation.

Runs a separate channel or phase estimator along each survivor path of the Viterbi algorithm, using its own tentative decisions.

Per-survivor processing (PSP) is a way to run the Viterbi algorithm when some parameter of the channel is unknown or drifts: the taps of the channel, the carrier phase or the symbol timing. A conventional receiver has one estimator, driven by the tentative decisions of the detector. Those decisions are reliable only after a delay, when the survivors have merged, so the estimator works with old data. PSP gives each survivor its own estimator and drives it with the symbols of that survivor, at once. The branch metrics of a survivor use its own estimate. The best path then comes with the estimate that fits it best. Raheli, Polydoros and Tzou gave the general principle in 1995.

In plain words

The Viterbi algorithm keeps one best path into each state. Each of these paths is a hypothesis about the symbols sent so far. If the path is right, the symbols on it are known, and the channel can be estimated as if from a training sequence. So every path gets its own estimator, trained on its own symbols. Wrong paths get poor estimates and soon fall behind. The right path gets a good estimate with no delay. The cost is one estimator per state instead of one in total.

When it applies

The template

  1. Attach an estimate to each state. Next to the metric and the back pointer, each state holds the parameter estimate of its survivor.
  2. Score branches with the estimate of their start state. A branch from the state ss with the new symbol aa gets the metric ∣yn−f^(s)⊤x∣2\lvert y_n - \hat f(s)^{\top} \mathbf{x} \rvert^2, where x=(a,s)\mathbf{x} = (a, s) holds the symbols of that branch.
  3. Add, compare and select as usual. Each next state keeps its best incoming branch.
  4. Update along the winner. The estimate of the next state is the estimate of the winning start state, updated by one step of the estimator with the error and the symbols of the winning branch.

For a channel with LL taps and LMS with the step size β\beta, the receiver is:

  1. PSP-VITERBI(y, f0, β, pre)
  2. 1Γ(start) ← 0, f̂(start) ← f0 ▷ start = the known symbols pre
  3. 2for n ← 0 to N - 1
  4. 3for each reached state s and each symbol a
  5. 4e ← y[n] - f̂(s)ᵀ (a, s) ▷ the prediction error with the estimate of s
  6. 5keep for t = first L-1 entries of (a, s) the branch with the smallest Γ(s) + e²
  7. 6for each next state t: f̂(t) ← f̂(s) + β e (a, s) ▷ s, a, e of the winning branch
  8. 7trace back from the state with the smallest Γ

Correctness. By induction on nn, the estimate of each state is the LMS estimate run on the symbols of its own survivor, so it never uses a decision from another path, and it uses the newest symbol without a delay. With β=0\beta = 0, every estimate stays f0f_0, and the receiver is exactly the Viterbi equalizer for f0f_0, which returns the maximum likelihood sequence. With β>0\beta > 0 it is not the maximum likelihood detector for an unknown channel, but a search in which every path is scored by the prediction errors of its own adaptive estimate. The proofs folder has the details.

Cost. With MM symbols and ML−1M^{L-1} states, each step evaluates MLM^L branches and updates ML−1M^{L-1} estimates, each at O(L)O(L). A block of NN samples costs O(NLML)O(N L M^L) time in the word RAM with unit-cost real arithmetic, the same order as the Viterbi equalizer, and O(NML−1)O(N M^{L-1}) space for the back pointers. A conventional receiver has one estimator instead of ML−1M^{L-1}, which matters when the estimator is expensive, such as RLS with O(L2)O(L^2) per update.

Classic examples

A drifting channel. BPSK on the channel with the taps fn,k=bk+0.4sin⁡(2πn/500+k)f_{n,k} = b_k + 0.4 \sin(2\pi n/500 + k), b=(1,0.5,0.3)b = (1, 0.5, 0.3), noise variance 0.05 and 3000 symbols (seed 8001). The tests count the errors:

receiver errors in 3000 agreement with the known-channel Viterbi
Viterbi that knows fnf_n at every time 1
Viterbi with the fixed estimate f0f_0 297
PSP with LMS, β=0.05\beta = 0.05 0 2999 of 3000

With β=0.01\beta = 0.01 and 0.020.02, PSP made 70 and 23 errors on the same data, because the estimates lag behind the drift.

Learning the channel from a wrong start. On the fixed channel (1,0.5,0.3)(1, 0.5, 0.3) with noise variance 0.05 and 1000 symbols (seed 8003), the Viterbi equalizer for the wrong channel (1,0,0)(1, 0, 0) makes 44 errors. PSP from the same wrong start with β=0.02\beta = 0.02 makes no errors, and its final estimate of the best survivor is (1.010,0.533,0.311)(1.010, 0.533, 0.311).

Carrier phase. For a channel yn=ejθn(f⊤xn)+wny_n = e^{j\theta_n} (f^{\top} \mathbf{x}_n) + w_n with an unknown, slowly drifting phase, each survivor runs its own phase-locked loop, driven by the phase error between yny_n and the noiseless output of its branch. This is decision-directed carrier recovery with the decisions of each survivor, and it avoids the delay that a single loop driven by the detector output would have.

Decision feedback in reduced-state detectors. In reduced-state sequence estimation and delayed decision feedback sequence estimation, the trellis keeps only part of the channel memory, and each survivor cancels the rest with its own past symbols. This is per-survivor processing applied to the symbols that the state does not hold.

Variations

  • The estimator. LMS is the cheapest. RLS and the Kalman filter track faster channels at O(L2)O(L^2) per survivor and step.
  • Fewer estimators. Keep estimators only for the best few survivors, or share one estimator among the states that differ only in old symbols, to cut the cost.
  • Blind start. With no training, PSP can start from a rough estimate and let the survivors learn the channel, as in the second example. The sign of the channel is ambiguous for BPSK, so a known start or differential coding is still needed.
  • Tree and list searches. The same idea works in the M-algorithm and in other breadth-first searches, where each kept path carries its estimate.
  • Soft output. In iterative receivers, the per-survivor estimates can feed soft-output detectors, as in turbo equalization.

Pitfalls

  • The step size. Too small, and the estimates lag behind the drift (70 errors with β=0.01\beta = 0.01 in the first example). Too large, and the noise in the estimates raises the error rate. Tune it to the drift rate and the SNR.
  • No ML guarantee with adaptation. With β>0\beta > 0, a wrong path can fit its own estimate well and win, in particular when the channel is badly known at the start. The detector is a good heuristic, not the ML detector for an unknown channel.
  • Phase and sign ambiguity. A blind PSP receiver can converge to −f-f with all symbols inverted, or to a rotated channel for QAM. Use a known preamble or differential coding.
  • Cost with many states. With ML−1M^{L-1} states, each with an RLS estimator, the cost grows fast. Combine PSP with a reduced-state trellis.
  • Ties in the metric. When two branches into a state have equal metrics, the choice decides which estimate survives. Break ties in a fixed order so that the result is reproducible.

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.

per_survivor_processing.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/per-survivor-processing/. The authors are listed in prov/24BB6C.jsonl.

"""Per-survivor processing: a Viterbi equalizer with one LMS channel estimate per survivor.

The received samples are y[n] = sum_k f_n[k] x[n - k] + noise, with real symbols
and channel taps f_n that may drift slowly. The trellis state is the last
L - 1 symbols, most recent first. Every state keeps its own channel estimate.
A branch from state s with the new symbol a is scored with the estimate of s,
and after the add-compare-select step, the estimate of the winning branch is
updated by one LMS step that uses the symbols of that branch. So every
estimate is driven by the decisions of its own survivor, with no decision
delay. With the step size 0, the receiver is the plain Viterbi equalizer for
the channel f0.
"""

from itertools import product


def psp_viterbi(
    y: list[float],
    f0: list[float],
    step: float,
    alphabet: tuple[float, ...] = (-1.0, 1.0),
    pre: list[float] | None = None,
) -> tuple[list[float], list[float]]:
    """Return the decisions and the final channel estimate of the best survivor.

    pre holds the L - 1 symbols sent before y[0], in time order. The default is
    alphabet[0] repeated, a known start.
    """
    m = len(f0) - 1
    if m < 0:
        raise ValueError("the channel needs at least one tap")
    if pre is None:
        pre = [alphabet[0]] * m
    if len(pre) != m:
        raise ValueError("pre must hold len(f0) - 1 symbols")
    start = tuple(reversed(pre))
    metric = {start: 0.0}  # @line L1
    est = {start: [float(v) for v in f0]}
    back = []
    for yn in y:  # @line L2
        best = {}
        for s, ms in metric.items():  # @line L3
            f = est[s]
            for a in alphabet:
                x = (a,) + s
                e = yn - sum(fk * xk for fk, xk in zip(f, x))  # @line L4
                cand = ms + e * e
                t = x[:m]
                if t not in best or cand < best[t][0]:  # @line L5
                    best[t] = (cand, s, a, e, x)
        metric, new_est, bp = {}, {}, {}
        for t, (cand, s, a, e, x) in best.items():
            metric[t] = cand
            new_est[t] = [fk + step * e * xk for fk, xk in zip(est[s], x)]  # @line L6
            bp[t] = (s, a)
        est = new_est
        back.append(bp)
    t = min(metric, key=metric.get)  # @line L7
    final = est[t]
    out = []
    for bp in reversed(back):
        s, a = bp[t]
        out.append(a)
        t = s
    out.reverse()
    return out, final


def drifting_channel(n: int, base: list[float], depth: float, period: float) -> list[list[float]]:
    """Taps that drift as base[k] + depth sin(2 pi i / period + k), for i < n."""
    import math

    return [[b + depth * math.sin(2 * math.pi * i / period + k) for k, b in enumerate(base)] for i in range(n)]


def transmit(x: list[float], taps: list[list[float]], pre: list[float]) -> list[float]:
    """Noiseless output of the time-varying channel, taps[n] used at time n."""
    full = list(pre) + list(x)
    m = len(pre)
    return [sum(f[k] * full[m + n - k] for k in range(len(f))) for n, f in enumerate(taps)]
test_per_survivor_processing.py 103 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/per-survivor-processing/. The authors are listed in prov/24BB6C.jsonl.

import math
import random
from itertools import product

import pytest

from per_survivor_processing import drifting_channel, psp_viterbi, transmit


def ml_by_search(y, f, pre, alphabet=(-1.0, 1.0)):
    best = None
    for x in product(alphabet, repeat=len(y)):
        r = transmit(list(x), [f] * len(y), pre)
        cost = sum((a - b) ** 2 for a, b in zip(y, r))
        if best is None or cost < best[0]:
            best = (cost, list(x))
    return best[1]


def genie_viterbi(y, taps, pre, alphabet=(-1.0, 1.0)):
    # the Viterbi equalizer that knows the channel at every time
    m = len(taps[0]) - 1
    metric = {tuple(reversed(pre)): 0.0}
    back = []
    for n, yn in enumerate(y):
        best = {}
        for s, ms in metric.items():
            for a in alphabet:
                x = (a,) + s
                e = yn - sum(f * v for f, v in zip(taps[n], x))
                if x[:m] not in best or ms + e * e < best[x[:m]][0]:
                    best[x[:m]] = (ms + e * e, s, a)
        metric = {t: v[0] for t, v in best.items()}
        back.append({t: (v[1], v[2]) for t, v in best.items()})
    t = min(metric, key=metric.get)
    out = []
    for bp in reversed(back):
        t, a = bp[t]
        out.append(a)
    return out[::-1]


def errors(a, b):
    return sum(u != v for u, v in zip(a, b))


def test_step_zero_is_the_viterbi_equalizer() -> None:
    rng = random.Random(8002)
    for _ in range(20):
        f = [1.0] + [rng.uniform(-0.8, 0.8) for _ in range(rng.randint(0, 2))]
        pre = [rng.choice((-1.0, 1.0)) for _ in range(len(f) - 1)]
        x = [rng.choice((-1.0, 1.0)) for _ in range(9)]
        y = [v + rng.gauss(0, 0.6) for v in transmit(x, [f] * 9, pre)]
        d, est = psp_viterbi(y, f, 0.0, pre=pre)
        assert d == ml_by_search(y, f, pre)
        assert est == f


def test_drifting_channel() -> None:
    # taps 1, 0.5, 0.3 plus 0.4 sin(2 pi n / 500 + k), noise variance 0.05, seed 8001
    rng = random.Random(8001)
    n = 3000
    taps = drifting_channel(n, [1.0, 0.5, 0.3], 0.4, 500)
    x = [rng.choice((-1.0, 1.0)) for _ in range(n)]
    pre = [-1.0, -1.0]
    y = [v + rng.gauss(0, math.sqrt(0.05)) for v in transmit(x, taps, pre)]
    genie = genie_viterbi(y, taps, pre)
    fixed, _ = psp_viterbi(y, taps[0], 0.0, pre=pre)
    psp, _ = psp_viterbi(y, taps[0], 0.05, pre=pre)
    assert errors(genie, x) == 1
    assert errors(fixed, x) == 297
    assert errors(psp, x) == 0
    assert errors(psp, genie) == 1  # agrees with the genie on 2999 of 3000 symbols
    slow, _ = psp_viterbi(y, taps[0], 0.01, pre=pre)
    assert errors(slow, x) == 70  # a small step lags behind the drift


def test_learns_the_channel_from_a_wrong_start() -> None:
    rng = random.Random(8003)
    n = 1000
    h = [1.0, 0.5, 0.3]
    x = [rng.choice((-1.0, 1.0)) for _ in range(n)]
    pre = [-1.0, -1.0]
    y = [v + rng.gauss(0, math.sqrt(0.05)) for v in transmit(x, [h] * n, pre)]
    blind, _ = psp_viterbi(y, [1.0, 0.0, 0.0], 0.0, pre=pre)
    d, est = psp_viterbi(y, [1.0, 0.0, 0.0], 0.02, pre=pre)
    assert errors(blind, x) == 44
    assert errors(d, x) == 0
    assert max(abs(a - b) for a, b in zip(est, h)) < 0.05


def test_no_memory_and_input_checks() -> None:
    d, est = psp_viterbi([0.9, -1.2, 0.1], [1.0], 0.1)
    assert d == [1.0, -1.0, 1.0]
    # f = 1 + 0.1(-0.1) = 0.99, then 0.99 + 0.1(-0.21)(-1) = 1.011, then 1.011 + 0.1(-0.911) = 0.9199
    assert abs(est[0] - 0.9199) < 1e-12
    with pytest.raises(ValueError):
        psp_viterbi([1.0], [], 0.1)
    with pytest.raises(ValueError):
        psp_viterbi([1.0], [1.0, 0.5], 0.1, pre=[1.0, 1.0])

Exercises

  1. Show by induction that, after time nn, the estimate of each state is the LMS estimate run on the symbols of its own survivor.
  2. Show that with β=0\beta = 0 the receiver gives the same decisions as the Viterbi equalizer for f0f_0.
  3. For the channel with one tap f=1f = 1, the step size 0.1 and y=(0.9,−1.2,0.1)y = (0.9, -1.2, 0.1), compute the decisions and the final estimate by hand. (The answer is (+1,−1,+1)(+1, -1, +1) and 0.9199.)
  4. A conventional adaptive Viterbi equalizer updates one estimate with the decision made DD steps back. Explain why it must predict the channel DD steps ahead on a fast-fading channel, and why PSP does not.
  5. Count the operations per symbol for PSP with RLS on a channel with LL taps and MM symbols, and compare them with a single RLS estimator.
Proof: Each survivor's estimate is the LMS estimate driven by that survivor's own symbols, and with the step size 0 the receiver is the maximum likelihood Viterbi equalizerfull

The received samples are yn=∑k=0L−1fn,k xn−k+wny_n = \sum_{k=0}^{L-1} f_{n,k}\, x_{n-k} + w_n with real symbols xnx_n from an alphabet of MM points, and the symbols x−1,…,x−(L−1)x_{-1}, \ldots, x_{-(L-1)} before the block are known (the argument pre). The trellis state at time nn is sn=(xn−1,…,xn−L+1)s_n = (x_{n-1}, \ldots, x_{n-L+1}), most recent first. For the state ss and the new symbol aa, the branch vector is x=(a,s)\mathbf{x} = (a, s), of length LL, and the next state is the first L−1L - 1 entries of x\mathbf{x}. Each state ss that is reached holds a metric Γ(s)\Gamma(s), a channel estimate f^(s)\hat f(s) and a back pointer. The step size is β≥0\beta \ge 0.

Lemma 1 (one survivor per state). After time nn, every state tt that is reached has exactly one survivor: the sequence x0,…,xnx_0, \ldots, x_n obtained by following the back pointers from tt. Its metric is

Γ(t)=∑i=0n(yi−f^i⊤xi)2,\Gamma(t) = \sum_{i=0}^{n} \big(y_i - \hat f_i^{\top} \mathbf{x}_i\big)^2,

where xi\mathbf{x}_i is the branch vector of the survivor at time ii and f^i\hat f_i is the estimate that the survivor held before time ii.

Proof. By induction on nn. Before time 0 only the known start state is reached, with metric 0 (line L1). At time nn, line L3 extends every reached state ss by every symbol aa, line L4 computes the error e=yn−f^(s)⊤xe = y_n - \hat f(s)^{\top} \mathbf{x} with the estimate of ss, and line L5 keeps, for each next state tt, the branch with the smallest Γ(s)+e2\Gamma(s) + e^2. The kept branch extends the survivor of ss, so the survivor of tt is the survivor of ss followed by aa, and its metric is the metric of ss plus the new term. □\square

Lemma 2 (the estimate follows its own survivor). After time nn, the estimate of the state tt is the result of the LMS recursion

f^i+1=f^i+β (yi−f^i⊤xi) xi,f^0=f0,\hat f_{i+1} = \hat f_i + \beta\, \big(y_i - \hat f_i^{\top} \mathbf{x}_i\big)\, \mathbf{x}_i, \qquad \hat f_0 = f_0,

run for i=0,…,ni = 0, \ldots, n on the symbols xi\mathbf{x}_i of the survivor of tt.

Proof. By induction on nn, with Lemma 1. Line L6 computes the estimate of tt from the estimate of the winning predecessor ss, with the error and the branch vector of the winning branch. By the induction hypothesis, the estimate of ss is the LMS result on the survivor of ss, and the survivor of tt is that survivor followed by the winning branch. □\square

So no estimate uses a symbol that its own survivor does not contain, and every estimate is updated at time nn with the symbol xnx_n of its survivor, without a decision delay. A receiver with one estimator must wait until the survivors merge before it can trust a decision. Here each hypothesis is carried with its own channel.

Theorem 1 (step size 0). If β=0\beta = 0, the decisions equal the maximum likelihood sequence for the channel f0f_0 and white Gaussian noise, and the returned estimate is f0f_0.

Proof. With β=0\beta = 0, line L6 copies the estimate, so by Lemma 2 every estimate is f0f_0 at every time. Then the branch metric in line L4 is (yn−f0⊤x)2(y_n - f_0^{\top} \mathbf{x})^2, the same for every survivor, and the metric of Lemma 1 is the squared distance between yy and the noiseless output of the survivor. This is the add-compare-select of the Viterbi algorithm on the trellis of the channel f0f_0. The cost of a whole sequence is a sum of branch costs that depend only on the state and the new symbol, so the principle of optimality applies: if the best sequence passes through the state tt at time nn, its first n+1n + 1 symbols are the best path into tt, which is the survivor of tt. Line L7 takes the end state with the smallest metric and follows the back pointers, so it returns the sequence with the smallest squared distance. For white Gaussian noise this is the maximum likelihood sequence. □\square

Theorem 2 (the cost). With ML−1M^{L-1} states, each time step evaluates MLM^L branches at O(L)O(L) each and updates ML−1M^{L-1} estimates at O(L)O(L) each. A block of NN samples costs O(NLML)O(N L M^L) time, the same order as the Viterbi equalizer with a known channel, and O(NML−1+LML−1)O(N M^{L-1} + L M^{L-1}) space for the back pointers and the estimates.

Proof. Count the work in lines L3 to L6 for one time step, and multiply by NN. The traceback in line L7 costs O(N)O(N). □\square

With β>0\beta > 0, the receiver is not the maximum likelihood detector for an unknown channel. Lemma 2 gives what it is: a Viterbi search in which every path is scored by the prediction errors of its own adaptive channel estimate. The page reports measured error counts for this case.

References

  1. Riccardo Raheli, Andreas Polydoros and Ching-Kae Tzou, Per-survivor processing: a general approach to MLSE in uncertain environments, IEEE Transactions on Communications 43(2/3/4), 1995, pages 354 to 364, the principle of per-survivor processing, with channel identification, phase tracking and reduced-state examples

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 proofH2 full proof
  • correctness: no review record reviews/24BB6C/proof-correctness.yaml
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)
WritingW2 basic
  • three classic examples