Algorithmadvanced
Whitened matched filter
Also called Forney whitened matched filter.
A matched filter followed by a noise-whitening filter. It turns an ISI channel into a causal minimum-phase channel f with white noise, the front end of the Viterbi equalizer and the DFE.
- Solves
- Channel equalization
- Time
- O(T L^2 + K L) worst
- Space
- O(K + L) extra
- Where
- K = the number of samples; L = the number of channel taps; T = the number of root-finding iterations
- Model
- Real RAM
- Properties
- deterministiclinearneeds channeloutput minimum phasepreserves ml metric
- Evidence
- Proof sketchCode in 1 languages
- Origin
- G. David Forney Jr., 1972
The whitened matched filter (WMF) is the front end that Forney proposed for sequence detection on channels with intersymbol interference. It is a matched filter followed by a noise-whitening filter. The matched filter alone keeps all the information about the symbols, but its output noise is colored, with the same spectrum as the folded channel . The whitening filter removes the color, where is the minimum-phase spectral factor of . The output is with white noise of the same variance. So the receiver sees a new causal channel of the same length, with its energy as early as possible. The Viterbi equalizer runs on with a Euclidean metric. The Ungerboeck receiver uses the matched filter output directly and needs no whitening. The decision feedback equalizer and reduced-state sequence estimation work best on the minimum-phase channel, because they decide the first taps first.
In plain words
A matched filter collects the energy of each symbol, but it makes neighbouring noise samples correlated. Many detectors assume the noise samples are independent. The whitening filter undoes the correlation without losing any information, and the noise becomes independent again. The price is that the channel the detector sees is a new one. Among all channels with the same frequency response magnitude, it is the one whose energy comes earliest. That is good for detectors that decide one symbol at a time, because the first tap carries the most signal.
The problem
The input is a channel known at the receiver and the received samples , with white . The output is a channel with , all zeros of in the closed unit disk and , and filtered samples with white . The two models give the same maximum likelihood decisions.
The algorithm
The folded spectrum , with , has the zeros of and their conjugate reciprocals. A spectral factor of keeps one zero of each pair. The minimum-phase factor keeps the one inside the unit circle. When is known, the zeros of give the factor directly.
WHITENED-MATCHED-FILTER(h, y)- 1
f ← MIN-PHASE-FACTOR(h) - 2
ρ_1, …, ρ_{L-1} ← the roots of h0 z^(L-1) + h1 z^(L-2) + … + h_{L-1} - 3
ρ'_i ← ρ_i if |ρ_i| ≤ 1, else 1/conj(ρ_i) ▷ reflect into the unit disk - 4
f ← γ Π_i (1 - ρ'_i z⁻¹), γ = |h0| Π_{|ρ_i|>1} |ρ_i| - 5
z[k] ← Σ_l conj(h[l]) y[k + l] for every k ▷ the matched filter - 6
for k ← K - 1 down to 0 ▷ the whitening filter 1/F*(1/z*) - 7
y'[k] ← (z[k] - Σ_{l≥1} conj(f[l]) y'[k + l]) / conj(f[0]) - 8
return f, y'
Line L2 finds the zeros with the Durand-Kerner method. Line L3 keeps the magnitude response: a zero outside the circle and the zero give the same up to the factor , which line L4 puts into . Line L5 is the matched filter, which correlates with . Lines L6 and L7 apply , an anticausal filter, by back substitution from the end of the block. If only is known, factor instead and keep the roots inside the circle.
Example
Take , a channel whose second tap is larger than its first. Its zero is at , outside the unit circle. Line L3 reflects it to , and line L4 gives , so . Both channels have and . Send with no noise:
| 0 | 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|---|
| 0.5 | 0.5 | -1.5 | -0.5 | 1.5 | 1 | |
| 0.75 | -1.25 | -1.25 | 1.25 | 1.75 | 0.5 | |
| 1 | -0.5 | -1.5 | 0.5 | 1.5 | 0.5 | |
| 1 | -0.5 | -1.5 | 0.5 | 1.5 | 0.5 |
The back substitution starts at with . The output is exactly. On the original channel, a zero-forcing DFE with one feedforward tap has the noise gain . On the whitened channel it has , which is 6 dB better.
On the channel B of Proakis, , the zeros are at and . The second one is reflected to , and . The change is small, because the channel is almost linear phase with both zeros near the circle.
Correctness
Claim. on the unit circle and is minimum phase. Without noise, exactly. For any noise and any candidate sequence , , so maximum likelihood on with the channel gives the same decisions as on with . On an infinite sequence, the noise after the filter is white with variance .
Key step. Equal magnitudes give equal autocorrelations, so for the full convolution matrices. The back substitution solves , so the cross terms of the two metrics agree too. The noise passes through , which is allpass. The proofs folder has the details, and also the proof that has the largest partial energies among all factors.
Proof: The whitened matched filter gives the minimum-phase channel with white noise, and maximum likelihood on its output equals maximum likelihood on the received samplesfull
The channel taps are with and , and . The received block is , where , is the full convolution matrix with , and . Write .
Lemma 1 (the factor). Write , where are the roots of (line L2). Let if and otherwise (line L3), and with (line L4). Then for every , all zeros of are in the closed unit disk, and the autocorrelations of and are equal: for every .
Proof. For and , , and on the unit circle, so this is . Multiplying over the factors gives on the circle. The autocorrelation is the -th Fourier coefficient of , so equal magnitudes give equal autocorrelations.
So , which is the spectral factorization of the folded spectrum. In particular, .
Lemma 2 (the matrices). Let be the full convolution matrix of . Then .
Proof. The entry of is , summed over all because the full convolution keeps every product. This is (with ), and the same holds for . Lemma 1 ends the proof.
The filter. Let and be the lower triangular Toeplitz matrices of and (the convolution truncated to outputs). Line L5 computes , the matched filter, with the samples after the block taken as 0. Lines L6 and L7 solve by back substitution, from down to 0. is upper triangular with the diagonal , so the solution exists and is unique.
Theorem 1 (noiseless output). If , then exactly.
Proof. Pad with zeros to length . Then and , because the full convolutions have length . We need . Row of the right side is . A product is nonzero only for , so the inner sum runs over all and equals , the full autocorrelation. The same holds for , and Lemma 1 gives . So , and uniqueness gives .
Theorem 2 (the same maximum likelihood decisions). For every and every candidate supported on the first entries,
which does not depend on . So the sequence that minimizes over any alphabet is the maximum likelihood sequence for .
Proof. Expand both norms. The cross terms are and , and , so they are equal. The quadratic terms are and , equal by Lemma 2.
Theorem 3 (white noise, for the infinite filter). On an infinite sequence, the noise after the filter is with , and . So the output noise is white with variance , and with i.i.d. If no zero of lies on the unit circle, is a stable anticausal filter.
Proof. The filter is after . On the unit circle and the same for , so by Lemma 1. A linear filter with maps white noise of spectrum to white noise of spectrum , and a linear map of a circular Gaussian process is circular Gaussian. The zeros of are at , which lie outside the unit disk when , so the anticausal inverse is stable.
For a finite block the back substitution starts at the end of the block, so the last samples carry an edge effect, which decays at the rate of the largest away from the end. Theorem 2 needs no whiteness: it holds exactly for the finite block.
Theorem 4 (minimum phase has the most energy first). Among all with on the unit circle that are obtained by reflecting a subset of the zeros, the factor has the largest partial energy for every .
Proof. Compare a factor with the zero () and the same factor with , with the gain kept so that the magnitudes on the circle agree: and up to a unit factor. Write for the taps of , with for . Then and , and
by a direct expansion where the cross terms cancel and the terms with telescope. Reflecting one zero at a time from any factor to never lowers a partial energy.
Complexity
The roots cost for iterations of Durand-Kerner on a polynomial of degree , and building costs . Lines L5 to L7 cost per sample, so samples cost in the real RAM, with extra space for and . The filter needs the whole block before it can start, because it runs backward. A stream receiver uses a truncated FIR approximation of with a delay.
Properties
- Information lossless. The matched filter outputs are sufficient statistics, and the whitening filter is invertible, so no information is lost.
- Same metric. The Euclidean metric on differs from the metric on by a constant for each block, so every maximum likelihood detector gives the same answer on both.
- White noise. The noise map is allpass, so the noise stays white with variance . In a finite block, the samples near the end carry an edge effect.
- Causal and minimum phase. The output channel has taps, no precursors, and the most energy in its first taps among all channels with the same magnitude response.
- Anticausal filter. is stable only as an anticausal filter, so a block receiver runs it backward and a stream receiver needs a delay.
- Unit circle zeros. If has a zero on the unit circle, the whitening filter has a pole on the circle and the inverse is unstable. The Ungerboeck receiver avoids the whitening step.
Variants and improvements
- From the autocorrelation. If only is known, factor the polynomial of degree and keep the roots inside the circle. Other methods are Bauer's method, the Cholesky factorization of a large Toeplitz matrix, and the cepstral method.
- Linear prediction. The whitening filter is a prediction error filter for the matched filter noise, so a long linear prediction filter from the Levinson recursion approximates it.
- MMSE prefilter. The feedforward filter of the MMSE-DFE also leaves a channel with its energy first, and it tends to the WMF at high SNR. At lower SNR it allows a little precursor ISI and bias for less noise. For RSSE and DFE receivers it often replaces the WMF.
- Fractionally spaced front end. With more than one sample per symbol, the matched filter is applied in continuous time or at the higher rate, and the output is then sampled at the symbol rate before whitening.
When to use it
Use the WMF as the front end of a Viterbi equalizer with a Euclidean metric, of a DFE or of reduced-state sequence estimation, when the channel is known and has no zeros on the unit circle. For a full Viterbi equalizer, the Ungerboeck receiver avoids the whitening and works on the matched filter output. For suboptimal detectors that decide early, the minimum-phase output is the main reason to use the WMF.
Pitfalls
- Running the whitening filter forward. is unstable as a causal filter, because its pole lies outside the circle. Run it backward or use a truncated anticausal FIR.
- Taking the maximum-phase factor. Keeping the roots outside the circle gives a valid factor with the energy last, which ruins a DFE or an RSSE.
- Forgetting the conjugates. For complex channels, the matched filter correlates with , and the whitening uses . A real test channel hides the mistake.
- Zeros near the circle. The whitening filter then decays slowly, so the edge effect at the block end is long, and the root finder needs more iterations. The channel B of Proakis is such a case.
- A gain error in . The scale must give . A wrong scale changes the noise variance that the metric assumes.
Implementations
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.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/whitened-matched-filter/. The authors are listed in prov/35K4A5.jsonl.
"""Forney's whitened matched filter on a discrete-time ISI channel.
The channel is y[k] = sum_l h[l] x[k-l] + w[k] with w white CN(0, N0). The
matched filter output z = h~ * y (h~[l] = conj(h[-l])) has the folded spectrum
R(z) = H(z) H*(1/z*) of the channel autocorrelation, and colored noise.
Factor R(z) = F(z) F*(1/z*) with F minimum phase (all zeros inside or on the
unit circle). The whitening filter 1/F*(1/z*) after the matched filter gives
y' = f * x + n' with n' white CN(0, N0) again. The receiver can then run the
Viterbi equalizer on the causal, minimum-phase channel f.
Here the receiver knows h, so F is found by reflecting the zeros of H(z) that lie
outside the unit circle to their conjugate reciprocals, and scaling so that
|F| = |H| on the unit circle. The zeros come from the Durand-Kerner iteration.
"""
import cmath
import math
def autocorrelation(h: list[complex]) -> list[complex]:
"""R[k] = sum_l h[l + k] conj(h[l]) for k = 0..L-1; R[-k] = conj(R[k])."""
n = len(h)
return [sum(complex(h[l + k]) * complex(h[l]).conjugate() for l in range(n - k)) for k in range(n)]
def poly_roots(c: list[complex], iters: int = 500, tol: float = 1e-14) -> list[complex]:
"""The roots of c[0] z^d + c[1] z^(d-1) + ... + c[d] by the Durand-Kerner iteration."""
while c and c[0] == 0:
c = c[1:]
d = len(c) - 1
if d < 1:
return []
a = [complex(v) / c[0] for v in c]
rad = 1.0 + max(abs(v) for v in a[1:])
z = [rad * 0.9 * cmath.exp(2j * math.pi * (i + 0.25) / d) for i in range(d)]
for _ in range(iters):
move = 0.0
for i in range(d):
p = 0j
for v in a:
p = p * z[i] + v
den = 1 + 0j
for k in range(d):
if k != i:
den *= z[i] - z[k]
step = p / den if den != 0 else 1e-3
z[i] -= step
move = max(move, abs(step))
if move < tol * rad:
break
return z
def min_phase_factor(h: list[complex]) -> list[complex]:
"""The minimum-phase f with |F| = |H| on the unit circle and f[0] real and positive."""
while len(h) > 1 and h[-1] == 0:
h = h[:-1]
if not h or h[0] == 0:
raise ValueError("need h[0] != 0")
zeros = poly_roots(list(h)) # @line L2
gain = abs(h[0])
inside = []
for r in zeros: # @line L3
if abs(r) > 1.0:
gain *= abs(r)
inside.append(1.0 / r.conjugate())
else:
inside.append(r)
f = [complex(gain)]
for r in inside: # @line L4
f = [(f[i] if i < len(f) else 0) - (r * f[i - 1] if i >= 1 else 0) for i in range(len(f) + 1)]
return f
def all_spectral_factors(h: list[complex]) -> list[list[complex]]:
"""Every factor g with |G| = |H| on the unit circle, one per choice of reflected zeros (up to a phase)."""
zeros = poly_roots(list(h))
out = []
for mask in range(1 << len(zeros)):
gain = abs(h[0])
rs = []
for i, r in enumerate(zeros):
if mask >> i & 1:
gain *= abs(r)
rs.append(1.0 / r.conjugate())
else:
rs.append(r)
g = [complex(gain)]
for r in rs:
g = [(g[i] if i < len(g) else 0) - (r * g[i - 1] if i >= 1 else 0) for i in range(len(g) + 1)]
out.append(g)
return out
def freq(h: list[complex], w: float) -> complex:
"""H(e^{jw}) = sum_l h[l] e^{-jwl}."""
return sum(complex(v) * cmath.exp(-1j * w * l) for l, v in enumerate(h))
def whitened_matched_filter(h: list[complex], y: list[complex]) -> tuple[list[complex], list[complex]]:
"""The minimum-phase channel f and the whitened samples y' with y' = f * x + white noise.
y is the received block y[0..K-1]; samples after it are taken as 0. The
output has the same length as y.
"""
f = min_phase_factor(h) # @line L1
n, taps = len(y), len(h)
z = [sum(complex(h[l]).conjugate() * y[k + l] for l in range(taps) if k + l < n) for k in range(n)] # @line L5
out = [0j] * n
for k in range(n - 1, -1, -1): # @line L6
acc = z[k] - sum(f[l].conjugate() * out[k + l] for l in range(1, len(f)) if k + l < n)
out[k] = acc / f[0].conjugate() # @line L7
return f, out # @line L8
test_whitened_matched_filter.py 136 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/whitened-matched-filter/. The authors are listed in prov/35K4A5.jsonl.
import itertools
import math
import random
import pytest
from whitened_matched_filter import (
all_spectral_factors,
autocorrelation,
freq,
min_phase_factor,
poly_roots,
whitened_matched_filter,
)
def cn(rng, var):
s = math.sqrt(var / 2)
return complex(rng.gauss(0, s), rng.gauss(0, s))
def conv(a, b):
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 random_channel(rng, taps):
# zeros away from the unit circle, so the whitening filter decays fast
while True:
h = [cn(rng, 1.0) for _ in range(taps)]
if h[0] != 0 and all(abs(abs(r) - 1) > 0.15 for r in poly_roots(h)):
return h
def test_example_on_the_page() -> None:
f = min_phase_factor([0.5, 1])
assert max(abs(a - b) for a, b in zip(f, [1, 0.5])) < 1e-12
assert autocorrelation([0.5, 1]) == [1.25, 0.5]
f = min_phase_factor([0.407, 0.815, 0.407])
assert abs(sum(abs(v) ** 2 for v in f) - (0.407**2 * 2 + 0.815**2)) < 1e-12
x = [1, -1, -1, 1, 1]
y = conv([complex(v) for v in x], [0.5, 1])
_, yw = whitened_matched_filter([0.5, 1], y)
want = conv([complex(v) for v in x], [1, 0.5])
assert max(abs(a - b) for a, b in zip(yw, want)) < 1e-12
def test_roots_of_known_polynomials() -> None:
r = sorted(poly_roots([1, -3, 2]), key=lambda v: v.real)
assert abs(r[0] - 1) < 1e-12 and abs(r[1] - 2) < 1e-12
r = poly_roots([1, 0, 1])
assert sorted(round(v.imag, 12) for v in r) == [-1, 1]
def test_factor_has_the_same_spectrum_and_is_minimum_phase() -> None:
rng = random.Random(7401)
for _ in range(40):
h = random_channel(rng, rng.randint(1, 6))
f = min_phase_factor(h)
assert len(f) == len(h) and f[0].real > 0 and abs(f[0].imag) < 1e-12
for t in range(32):
w = 2 * math.pi * t / 32
assert abs(abs(freq(f, w)) ** 2 - abs(freq(h, w)) ** 2) < 1e-9
assert all(abs(r) <= 1 + 1e-9 for r in poly_roots(f))
rh, rf = autocorrelation(h), autocorrelation(f)
assert max(abs(a - b) for a, b in zip(rh, rf)) < 1e-9
def test_minimum_phase_factor_has_the_largest_partial_energies() -> None:
rng = random.Random(7402)
for _ in range(20):
h = random_channel(rng, rng.randint(2, 5))
f = min_phase_factor(h)
for g in all_spectral_factors(h):
for n in range(len(g)):
assert sum(abs(v) ** 2 for v in f[: n + 1]) >= sum(abs(v) ** 2 for v in g[: n + 1]) - 1e-9
def test_noiseless_output_is_f_convolved_with_x() -> None:
rng = random.Random(7403)
for _ in range(20):
h = random_channel(rng, rng.randint(1, 5))
x = [complex(rng.choice((-1, 1)), rng.choice((-1, 1))) for _ in range(30)]
f, yw = whitened_matched_filter(h, conv(x, h))
want = conv(x, f)
assert max(abs(a - b) for a, b in zip(yw, want)) < 1e-9
def test_ml_decisions_agree_before_and_after_the_filter() -> None:
# the two metrics differ by a constant, so the brute force minimizers agree on every vector
rng = random.Random(7404)
for _ in range(25):
h = random_channel(rng, rng.randint(2, 4))
n = 8
x = [complex(rng.choice((-1, 1))) for _ in range(n)]
y = [v + cn(rng, 0.5) for v in conv(x, h)]
f, yw = whitened_matched_filter(h, y)
best_y, best_w, diffs = None, None, []
for cand in itertools.product((-1, 1), repeat=n):
c = [complex(v) for v in cand]
my = sum(abs(a - b) ** 2 for a, b in zip(y, conv(c, h)))
mw = sum(abs(a - b) ** 2 for a, b in zip(yw, conv(c, f)))
diffs.append(my - mw)
if best_y is None or my < best_y[0]:
best_y = (my, cand)
if best_w is None or mw < best_w[0]:
best_w = (mw, cand)
assert best_y[1] == best_w[1]
assert max(diffs) - min(diffs) < 1e-8
def test_noise_map_is_white_away_from_the_block_end() -> None:
rng = random.Random(7405)
h = [0.3 + 0.2j, 1.0, -0.4j]
n = 40
cols = []
for t in range(n):
e = [0j] * n
e[t] = 1
cols.append(whitened_matched_filter(h, e)[1])
# entry (i, t) of the noise map is cols[t][i]
for i in range(20):
for k in range(20):
g = sum(cols[t][i] * cols[t][k].conjugate() for t in range(n))
assert abs(g - (1 if i == k else 0)) < 1e-6
def test_input_checks() -> None:
with pytest.raises(ValueError):
min_phase_factor([0, 1])
History
In 1972, Forney showed that the matched filter outputs at the symbol rate are sufficient statistics for the transmitted sequence on a linear Gaussian channel with ISI. He then whitened their noise with the minimum-phase spectral factor, obtaining a causal channel with white noise, and applied the Viterbi algorithm to it. The WMF made the maximum likelihood sequence estimator a practical receiver structure. In 1974, Ungerboeck showed that the Viterbi algorithm can work on the matched filter outputs directly, with a modified metric. The minimum-phase prefilter later became a standard part of reduced-state receivers.
References
- G. David Forney, Jr., Maximum-likelihood sequence estimation of digital sequences in the presence of intersymbol interference, IEEE Transactions on Information Theory 18(3), 1972, pages 363 to 378, the whitened matched filter and the discrete-time white-noise model
- John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Section 9.3 (the optimum receiver for channels with ISI), with 9.3-2 (the discrete-time model and the noise-whitening filter)
Where this leads
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 35K4A5 Edit this page History Report an error Markdown