Algorithmcore
Fractionally spaced equalizer
Also called T/2-spaced equalizer.
A linear equalizer with taps spaced T/2 (or T/L_s) apart and one output per symbol. It is insensitive to the sampling phase, and a finite FIR filter can remove the ISI exactly.
- Solves
- Channel equalization
- Time
- O(N^2 (N + L) + K N) worst
- Space
- O(N (N + L)) extra
- Where
- K = the number of symbols; L = the number of pulse samples; N = the number of equalizer taps
- Model
- Real RAM
- Properties
- biaseddeterministicinsensitive to sampling phaselinearneeds noise level
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Gottfried Ungerboeck, 1976
A fractionally spaced equalizer (FSE) is a linear equalizer whose input is sampled faster than the symbol rate, usually at samples per symbol, so its taps are apart. It still gives one output per symbol. A symbol-spaced equalizer works on samples taken at , after a matched filter, and the result depends on the phase : at a bad phase the aliased parts of the spectrum cancel and leave a null that no equalizer can fill. At , a pulse with less than 100 percent excess bandwidth, such as a root raised cosine pulse, does not alias, so the FSE sees the whole signal and can form the matched filter and the equalizer in one filter, whatever the phase. The design here is the MMSE design of the MMSE linear equalizer, applied to the polyphase model at . It has a second gift: the two sample phases act as two channels, and if they have no common zero, a finite FIR filter removes the ISI exactly, which a symbol-spaced FIR filter can never do. The same fact makes blind identification from second-order statistics possible.
In plain words
A receiver that samples once per symbol must sample at the right instant. If it samples between the right instants, parts of the signal fold onto each other and can cancel, and then the equalizer has nothing to work with. A fractionally spaced equalizer takes two samples per symbol instead. Two samples per symbol are enough to describe the received pulse completely, so no information is lost at any sampling instant, and a shift in time is just a different set of weights. The equalizer combines the samples of both phases and still outputs one value per symbol. It costs about twice as many taps for the same time span. Its weights are found in the same way as for the MMSE equalizer.
The problem
The input is the sampled pulse at samples per symbol, which includes the transmit filter, the channel and the sampling phase, normalized so that ; the noise power per sample; the symbol energy ; the number of taps ; and the delay . The samples are , with independent from sample to sample. This page uses , the case of the alias. The output is the tap vector that minimizes for the output , computed once per symbol, and the minimum .
The last samples satisfy , where and . Each row of shifts by one sample, but each column by samples, so is a block Toeplitz matrix, not a Toeplitz one.
The algorithm
FSE-MMSE(p, L_s, N_f, Δ, N0, Es)- 1
Q ← ⌊(L_p + N_f - 2) / L_s⌋ + 1 ▷ the symbols that reach the taps - 2
H[i][j] ← p[L_s j - i] for 0 ≤ i < N_f, 0 ≤ j < Q ▷ p[t] = 0 outside 0 .. L_p - 1 - 3
R ← Es H Hᴴ + N0 I - 4
r ← Es H e_Δ - 5
f ← R⁻¹ r - 6
c ← conj(f) ▷ z[k] = Σ c[i] y[L_s k - i] - 7
J ← Es - rᴴ f - 8
return c, J
Line L1 counts the symbols that touch the samples in the window. Line L2 is the polyphase convolution matrix: row holds the pulse samples that link sample to each symbol. Lines L3 to L7 are the Wiener solution of the MMSE equalizer. The only change from the symbol-spaced equalizer is the stride in line L2 and the decimation of the output: the filter runs at the sample rate, but only every -th output is computed. With the algorithm is the MMSE linear equalizer. To pick the delay, the implementation computes all values of from one inverse of and keeps the smallest.
Example
Exact zero forcing. Take and the pulse . Its even samples form the subchannel and its odd samples the subchannel , up to the factor ; their zeros are at and , so they share none. With , and :
| index 0 | 1 | 2 | 3 | |
|---|---|---|---|---|
| taps | 0 | -2/3 | 4/3 | 0 |
| combined response | 0 | 1 | 0 | 0 |
Check and . The ISI is gone with two nonzero taps, a span of one symbol, and . A symbol-spaced equalizer on one phase, the channel , with 2 taps (the same span) has at best even without noise, and no finite length brings it to 0. At the FSE gives with 4 taps, 0.153 with 8 and 0.133 with 16.
The sampling phase. Take a root raised cosine pulse with roll-off 0.35, truncated to 8 symbols on each side, and dB. The symbol-spaced MMSE equalizer has 15 taps after the matched filter, on the raised cosine samples . The FSE has 30 taps at , on the samples , normalized. Both use their best delay. The unbiased SINR is:
| phase | 0 | ||
|---|---|---|---|
| symbol-spaced, 15 taps | 20.00 dB | 19.41 dB | 11.16 dB |
| FSE at , 30 taps | 20.00 dB | 20.00 dB | 20.00 dB |
At 10 dB the same rows are 10.00, 9.44 and 6.89 dB against 10.00 dB at every phase. At the folded spectrum of the symbol-spaced samples is zero at half the symbol rate, so the symbol-spaced equalizer loses 8.8 dB at 20 dB SNR. The FSE reaches the matched filter bound at every phase.
Correctness
Claim. Lines L5 to L7 give the unique taps that minimize over all -tap filters at samples per symbol, and the minimum . At , if the even and odd subchannels have no common zero and each phase has enough taps, the FSE removes the ISI exactly, so with it reaches .
Key step. The samples in the window are with , so the problem is the same Wiener problem as for the MMSE linear equalizer, and completing the square gives the solution. For exact zero forcing, split the taps by phase: , where and are the subchannels. If and have no common root, the map on polynomials of degrees less than and is one to one, so it reaches . This is the Bezout identity of the extended Euclidean algorithm; its matrix is the Sylvester matrix, nonsingular when the resultant is not zero. The full proof, with the folded spectrum null at , is in the proofs folder. The phase insensitivity of a long FSE is cited from Ungerboeck and from Gitlin and Weinstein and checked numerically.
Proof: The MMSE fractionally spaced equalizer is the Wiener solution on the polyphase model, and at T/2 a finite FSE can remove the ISI exactly when the two phases share no zerofull
The receiver takes samples per symbol. The sampled pulse is , with outside this range and . The samples are , where the symbols are independent with mean zero and energy , and the noise samples are independent , independent of the symbols. The equalizer has taps and one output per symbol, , which estimates .
Lemma 1 (the polyphase model). Let and with (line L1). Then , where (line L2) and is the noise vector, with .
Proof. Put in the sum: . The term is nonzero only if , so and . So the symbols are all that enter . The noise samples are distinct for distinct , so they are independent with variance .
Theorem 1 (the Wiener solution). Let (line L3) and (line L4). If is nonsingular, which holds whenever , then with (lines L5 and L6) is the unique minimizer of over all -tap filters, and the minimum is (line L7). Moreover when , and for any taps , .
Proof. With , . By Lemma 1, and , because is entry of . Then . is positive semidefinite, and positive definite when it is nonsingular, so the last term is positive for . The formula for follows from and the independence of all terms. The closed form follows from the push-through identity : with .
With , , and Theorem 1 is the MMSE linear equalizer. The bias and the unbiased SINR follow exactly as on that page, since the proof there uses only .
Lemma 2 (the subchannels). For , define the subchannel and the subequalizer , the taps of phase . Then the combined response is . In the variable , .
Proof. . Write with . Then , so .
Theorem 2 (exact zero forcing at T/2). Let , let and have the degrees and in (their last coefficients are nonzero), and let and have no common complex root. If the even taps number at least and the odd taps at least , that is, and , then for every delay there are taps with exactly. So with the error is reachable, and when is nonsingular, the algorithm returns and these taps.
Proof. Use only the first even taps and the first odd taps, so with and with . By Lemma 2, , a polynomial of degree less than . The map is linear from a space of dimension to the space of polynomials of degree less than , also of dimension . It is injective: if , then divides ; since and have no common root, every root of , with its multiplicity, is a root of ; so divides , and forces , and then gives . So the map is onto, and is reached for each . These taps give by Theorem 1, and since always, the minimizer of Theorem 1 also has .
Remark (the converse). If and share a root , then for every choice of taps, while . So no FSE of any length removes the ISI exactly. In such cases can also lose rank, and then is singular at ; the implementation reports this. Note that always, so is a root of ; it is not shared as long as .
Remark (the symbol-spaced case). With , there is one subchannel, and needs to divide , so must be a single tap. A symbol-spaced FIR equalizer removes all ISI only when there is none to remove. This is why two phases help.
Lemma 3 (the null of the symbol-spaced model at half the symbol rate). Let be the spectrum of a real, even pulse , with for . The symbol-spaced samples have the folded spectrum , and at this is , which is zero at .
Proof. The folded spectrum follows from the Poisson sum formula for the samples of , whose transform is . At , only and give nonzero terms, since for the others. They are and . is real and even, so the sum is .
So the symbol-spaced equalizer after a raised cosine pulse with excess bandwidth sees a channel with a spectral null at the band edge when it samples at , and its MSE grows. The T/2 samples do not alias, because for , which is below the half sampling rate . The FSE then sees the whole spectrum, and a delay is only a linear phase. That the infinite-length FSE is exactly insensitive to is shown by Ungerboeck (1976) and by Gitlin and Weinstein (1981); this file does not prove it. The tests check it numerically for and .
Remark (the cost). Line L3 costs with , line L5 costs , and line L7 costs , once per channel and delay. One inverse of , a matrix, gives for every delay.
Complexity
Line L3 costs operations with , line L5 costs , and lines L4, L6 and L7 cost , once per channel and delay. With and , this is in the real RAM. Filtering costs complex multiplications per symbol, since only one output per symbol is computed, so symbols cost in total, with extra space. For the same time span, the FSE has times as many taps as a symbol-spaced equalizer, so its cost per symbol is times higher, and its design is about times higher.
Properties
- Insensitive to the sampling phase. At and an excess bandwidth below 100 percent, the samples do not alias, and a long FSE gives the same MSE at every phase, as in the table above.
- Matched filter included. The FSE can realize the matched filter and the equalizer in one filter, so the receive filter before it only has to reject the noise outside the band.
- Exact zero forcing with a finite filter. If the two phases share no zero, a finite FSE removes the ISI exactly; the needed length is at least the degree of the other phase, per phase.
- Biased. As for every MMSE design, .
- The noise per sample. With and noise per sample, the matched filter bound is , the same as for the symbol-spaced model after a matched filter, so the two can be compared directly.
- Not unique when too long. If exceeds the number of symbols in its window, is singular, and with many tap vectors give the same output; see the pitfalls.
Variants and improvements
- Other oversampling factors. or samples per symbol is enough when the excess bandwidth is small, and costs fewer taps; or 8 is used when the same samples also feed the timing recovery.
- Adaptive FSE. The LMS algorithm adapts the taps from training or decisions, with one update per symbol; see adaptive equalization. A small tap leakage keeps the taps bounded.
- Blind FSE. The constant modulus algorithm is often run on a fractionally spaced equalizer, and the second-order statistics at identify the channel, as in the Tong-Xu-Kailath method; see blind equalization.
- Fractionally spaced DFE. A decision feedback equalizer with a fractionally spaced feedforward filter and a symbol-spaced feedback filter combines both gains.
- Timing recovery. Because the FSE does not care about the phase, the timing loop, such as the Gardner detector, only has to track the symbol rate, not lock to a precise phase.
When to use it
Use an FSE when the sampling phase is not known or drifts, when the pulse has a significant excess bandwidth, or when the equalizer must also act as the matched filter. It is the usual choice in modems with an adaptive equalizer. Use a symbol-spaced equalizer when a matched filter and an accurate timing loop are already in place and the cost of extra taps matters, and use frequency-domain equalization for long channels in block systems.
Pitfalls
- Tap drift. When is larger than the number of symbols in the window, the out-of-band part of the input has no signal, and an adaptive FSE without leakage can let its taps grow there until they overflow. Add a small leakage or a small in the design.
- The noise model. The noise must be white at the sample rate for the formulas here. A narrow receive filter before the FSE colors the noise; then replace by the noise covariance.
- Mixing conventions. The pulse is normalized to at samples per symbol, not . With the wrong normalization the SNR is off by dB.
- Common zeros. If the two phases share a zero, for example when the pulse is a symbol-spaced pulse with zeros inserted, the FSE is no better than a symbol-spaced equalizer, and with the system is singular.
- The output rate. Only one output per symbol is used. Computing all outputs and then dropping half of them doubles the cost for nothing.
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
# 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)
fractionally_spaced_equalizer.py 100 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/fractionally-spaced-equalizer/. The authors are listed in prov/SDKX4V.jsonl.
"""The MMSE fractionally spaced equalizer (FSE) at L_s samples per symbol.
The receiver samples at L_s samples per symbol (L_s = 2 on the page, a
T/2-spaced equalizer). The sampled pulse p[0..L_p-1] includes the transmit
filter, the channel and the sampling phase, and is normalized so that
sum |p|^2 = 1. The samples are y[m] = sum_k x[k] p[m - L_s k] + w[m], with
symbols of energy Es and noise CN(0, N0) on each sample. The equalizer has
N_f taps spaced T/L_s apart and gives one output per symbol:
z[k] = sum_{i=0}^{N_f-1} c[i] y[L_s k - i], an estimate of x[k - D].
The regressor u = (y[L_s k], ..., y[L_s k - N_f + 1]) is u = H s + w with
H[i][j] = p[L_s j - i] and s = (x[k], x[k-1], ..., x[k-Q+1]), where
Q = floor((L_p + N_f - 2) / L_s) + 1. The MMSE taps solve the Wiener-Hopf
equations R f = r with R = Es H H^H + N0 I and r = Es H e_D, and c = conj(f).
With L_s = 1 this is the symbol-spaced MMSE linear equalizer.
"""
import cbb
def fse_matrix(p: list[complex], ls: int, nf: int) -> list[list[complex]]:
"""The N_f by Q matrix H with H[i][j] = p[L_s j - i], so that u = H s + w."""
if not p or ls < 1 or nf < 1:
raise ValueError("need a pulse, L_s >= 1 and N_f >= 1")
q = (len(p) + nf - 2) // ls + 1
pp = lambda t: complex(p[t]) if 0 <= t < len(p) else 0j
return [[pp(ls * j - i) for j in range(q)] for i in range(nf)]
def fse_mmse(p: list[complex], ls: int, nf: int, delay: int, n0: float, es: float = 1.0) -> tuple[list[complex], float]:
"""The N_f taps c, spaced T / L_s, that minimize E|z[k] - x[k - delay]|^2, and that minimum J."""
if n0 < 0 or es <= 0:
raise ValueError("need N0 >= 0 and Es > 0")
if not p or ls < 1 or nf < 1:
raise ValueError("need a pulse, L_s >= 1 and N_f >= 1")
q = (len(p) + nf - 2) // ls + 1 # @line L1
if not 0 <= delay < q:
raise ValueError("need 0 <= delay < Q")
hm = fse_matrix(p, ls, nf) # @line L2
big_r = [[es * sum(hm[i][t] * hm[k][t].conjugate() for t in range(q)) + (n0 if i == k else 0) for k in range(nf)] for i in range(nf)] # @line L3
r = [es * hm[i][delay] for i in range(nf)] # @line L4
try:
f = cbb.solve(big_r, r) # @line L5
except ValueError:
raise ValueError("R is singular: N0 = 0 and the phases of the pulse have a common zero, or N_f is too small") from None
c = [v.conjugate() for v in f] # @line L6
j = es - cbb.dot(r, f).real # @line L7
return c, j # @line L8
def mmse_by_delay(p: list[complex], ls: int, nf: int, n0: float, es: float = 1.0) -> list[float]:
"""J for every delay 0..Q-1 at once, as N0 Es times the diagonal of (Es H^H H + N0 I)^(-1); needs N0 > 0."""
if n0 <= 0:
raise ValueError("need N0 > 0")
hm = fse_matrix(p, ls, nf)
q = len(hm[0])
m = [[es * sum(hm[t][i].conjugate() * hm[t][k] for t in range(nf)) + (n0 if i == k else 0) for k in range(q)] for i in range(q)]
mi = cbb.inv(m)
return [n0 * es * mi[d][d].real for d in range(q)]
def best_delay(p: list[complex], ls: int, nf: int, n0: float, es: float = 1.0) -> tuple[int, list[complex], float]:
"""The delay with the smallest J, with its taps and J."""
js = mmse_by_delay(p, ls, nf, n0, es)
d = min(range(len(js)), key=lambda t: js[t])
c, j = fse_mmse(p, ls, nf, d, n0, es)
return d, c, j
def mse(c: list[complex], p: list[complex], ls: int, delay: int, n0: float, es: float = 1.0) -> float:
"""E|z[k] - x[k - delay]|^2 for any taps c: Es ||H^T c - e_delay||^2 + N0 ||c||^2."""
hm = fse_matrix(p, ls, len(c))
g = [sum(hm[i][j] * c[i] for i in range(len(c))) for j in range(len(hm[0]))]
if not 0 <= delay < len(g):
raise ValueError("need 0 <= delay < Q")
return es * sum(abs(v - (1 if j == delay else 0)) ** 2 for j, v in enumerate(g)) + n0 * cbb.norm2(c)
def received(x: list[complex], p: list[complex], ls: int) -> list[complex]:
"""The noiseless samples y[m] = sum_k x[k] p[m - L_s k], for m = 0 .. L_s (K - 1) + L_p - 1."""
up = [0j] * (ls * (len(x) - 1) + 1)
for k, v in enumerate(x):
up[ls * k] = complex(v)
return cbb.conv(up, p)
def equalize(c: list[complex], y: list[complex], ls: int, delay: int, count: int) -> list[complex]:
"""The outputs z[k] = sum_i c[i] y[L_s k - i] for k = delay .. delay + count - 1: the estimates of x[0 .. count - 1]."""
out = []
for k in range(delay, delay + count):
acc = 0j
for i, ci in enumerate(c):
m = ls * k - i
if 0 <= m < len(y):
acc += ci * y[m]
out.append(acc)
return out
test_fractionally_spaced_equalizer.py 150 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/fractionally-spaced-equalizer/. The authors are listed in prov/SDKX4V.jsonl.
import math
import random
import pytest
import cbb
from fractionally_spaced_equalizer import (
best_delay,
equalize,
fse_matrix,
fse_mmse,
mmse_by_delay,
mse,
received,
)
ROOT = math.sqrt(2.5)
PULSE = [1 / ROOT, 0.5 / ROOT, 0.5 / ROOT, 1 / ROOT] # even phase (1, 0.5), odd phase (0.5, 1), sum |p|^2 = 1
BETA = 0.35
def qpsk(rng):
return complex(rng.choice((-1, 1)), rng.choice((-1, 1))) / math.sqrt(2)
def slice_qpsk(z):
return complex(1 if z.real >= 0 else -1, 1 if z.imag >= 0 else -1) / math.sqrt(2)
def rrc(t):
# the root raised cosine pulse with T = 1 and roll-off BETA, of unit energy
if abs(t) < 1e-12:
return 1 - BETA + 4 * BETA / math.pi
if abs(abs(t) - 1 / (4 * BETA)) < 1e-9:
a = math.pi / (4 * BETA)
return BETA / math.sqrt(2) * ((1 + 2 / math.pi) * math.sin(a) + (1 - 2 / math.pi) * math.cos(a))
return (math.sin(math.pi * t * (1 - BETA)) + 4 * BETA * t * math.cos(math.pi * t * (1 + BETA))) / (math.pi * t * (1 - (4 * BETA * t) ** 2))
def rc(t):
# the raised cosine pulse, rrc convolved with itself, with rc(0) = 1
if abs(abs(t) - 1 / (2 * BETA)) < 1e-9:
return math.pi / 4 * math.sin(math.pi / (2 * BETA)) / (math.pi / (2 * BETA))
s = 1.0 if abs(t) < 1e-12 else math.sin(math.pi * t) / (math.pi * t)
return s * math.cos(math.pi * BETA * t) / (1 - (2 * BETA * t) ** 2)
def test_example_on_the_page() -> None:
c, j = fse_mmse(PULSE, 2, 4, 1, 0.0)
assert abs(j) < 1e-12
want = [0, -2 / 3 * ROOT, 4 / 3 * ROOT, 0]
assert max(abs(p - q) for p, q in zip(c, want)) < 1e-12
js = [fse_mmse(PULSE, 2, 4, d, 0.1)[1] for d in range(4)]
assert max(abs(p - q) for p, q in zip(js, [0.244207, 0.276292, 0.276292, 0.244207])) < 1e-6
# a T-spaced equalizer of the same span on either phase alone cannot reach J = 0
jt = min(fse_mmse([1 / ROOT, 0.5 / ROOT], 1, 2, d, 1e-12)[1] for d in range(3))
assert abs(jt - 1 / 21) < 1e-9 # the least-squares residual of 2 taps against 1 / (1 + 0.5 z^-1)
def test_ls_one_is_the_symbol_spaced_mmse_equalizer() -> None:
# for h = (1, 0.5), N = 5, N0 = 0.1 the MMSE linear equalizer has J = 0.11197 at the delay 1
c, j = fse_mmse([1, 0.5], 1, 5, 1, 0.1)
assert abs(j - 0.1119702) < 1e-7
assert abs(mse(c, [1, 0.5], 1, 1, 0.1) - j) < 1e-12
def test_closed_form_and_minimum_on_random_pulses() -> None:
rng = random.Random(8101)
for _ in range(40):
ls, lp, nf = rng.randint(1, 3), rng.randint(1, 7), rng.randint(1, 7)
p = [cbb.cn(rng, 1.0) for _ in range(lp)]
s = math.sqrt(cbb.norm2(p))
p = [v / s for v in p]
n0, es = rng.uniform(0.01, 0.5), rng.uniform(0.5, 2.0)
js = mmse_by_delay(p, ls, nf, n0, es)
d = rng.randrange(len(js))
c, j = fse_mmse(p, ls, nf, d, n0, es)
assert abs(j - js[d]) < 1e-9 and abs(mse(c, p, ls, d, n0, es) - j) < 1e-9
for scale in (1.0, 1e-3):
other = [v + scale * cbb.cn(rng, 1.0) for v in c]
assert mse(other, p, ls, d, n0, es) >= j - 1e-12
def test_matrix_matches_the_sampled_signal() -> None:
rng = random.Random(8102)
p = [cbb.cn(rng, 1.0) for _ in range(5)]
x = [qpsk(rng) for _ in range(12)]
y = received(x, p, 2)
hm = fse_matrix(p, 2, 6)
k = 8 # u = (y[2k], ..., y[2k - 5]) = H (x[k], ..., x[k - Q + 1])
u = [y[2 * k - i] for i in range(6)]
s = [x[k - j] for j in range(len(hm[0]))]
assert max(abs(a - b) for a, b in zip(u, cbb.matvec(hm, s))) < 1e-12
def test_zf_fse_recovers_noiseless_data_exactly() -> None:
rng = random.Random(8103)
for p, nf in ((PULSE, 4), (PULSE, 3), ([0.3, 0.8j, -0.4, 0.2, 0.1j, 0.5], 6)):
d = (len(p) + nf - 2) // 4 # a delay near the middle
c, j = fse_mmse(p, 2, nf, d, 0.0)
assert abs(j) < 1e-9
x = [qpsk(rng) for _ in range(300)]
z = equalize(c, received(x, p, 2), 2, d, len(x))
assert max(abs(a - b) for a, b in zip(z, x)) < 1e-9
assert [slice_qpsk(v) for v in z] == x
def test_insensitive_to_the_sampling_phase() -> None:
# T-spaced: matched filter, then samples rc(kT + tau). FSE: T/2 samples of rrc(t - tau). Both have Es / N0 = 20 dB.
n0, span = 0.01, 8
bound = n0 / (1 + n0) # J of the matched filter bound with no ISI
jt, jf = [], []
for tau in (0.0, 0.25, 0.5):
pt = [rc(k + tau) for k in range(-span, span + 1)]
jt.append(best_delay(pt, 1, 15, n0)[2])
pf = [rrc(m / 2 - tau) for m in range(-2 * span, 2 * span + 1)]
s = math.sqrt(sum(v * v for v in pf))
jf.append(best_delay([v / s for v in pf], 2, 30, n0)[2])
assert all(abs(j - bound) < 0.01 * bound for j in jf) # the FSE is within 1 percent at every phase
assert abs(jt[0] - bound) < 0.01 * bound
assert jt[2] > 5 * bound # a symbol-spaced equalizer at tau = T/2 loses more than 7 dB
assert jt[0] < jt[1] < jt[2]
def test_monte_carlo_mse_and_bias() -> None:
rng = random.Random(8104)
nf, n0, count = 8, 0.1, 20000
d, c, j = best_delay(PULSE, 2, nf, n0)
x = [qpsk(rng) for _ in range(count)]
y = cbb.awgn(rng, received(x, PULSE, 2), n0)
z = equalize(c, y, 2, d, count)
inner = range(nf, count - nf)
got = sum(abs(z[k] - x[k]) ** 2 for k in inner) / len(inner)
assert abs(got - j) < 0.05 * j # 20000 symbols, seed 8104
gain = sum(z[k] * x[k].conjugate() for k in inner) / len(inner)
assert abs(gain - (1 - j)) < 0.02 # the MMSE output is biased by 1 - J / Es
def test_errors() -> None:
with pytest.raises(ValueError):
fse_mmse([1, 1, 0.5, 0.5], 2, 4, 0, 0.0) # both phases are (1, 0.5): a common zero, so R is singular
with pytest.raises(ValueError):
fse_mmse(PULSE, 2, 4, 4, 0.1) # Q = 4, so the delay must be at most 3
with pytest.raises(ValueError):
fse_mmse(PULSE, 0, 4, 0, 0.1)
with pytest.raises(ValueError):
mmse_by_delay(PULSE, 2, 4, 0.0)
History
Ungerboeck's 1976 paper analyzed the equalizer with fractional tap spacing and showed that its performance does not depend on the sampling phase, which simplifies the clock recovery. Gitlin and Weinstein compared the equalizer with the symbol-spaced one in 1981. In the 1990s, the view of the samples as two channels led to blind identification from second-order statistics, and Treichler, Fijalkow and Johnson asked in 1996 how long a fractionally spaced equalizer should be.
References
- Gottfried Ungerboeck, Fractional tap-spacing equalizer and consequences for clock recovery in data modems, IEEE Transactions on Communications 24(8), 1976, pages 856 to 864, the insensitivity of the fractionally spaced equalizer to the sampling phase
- R. D. Gitlin and S. B. Weinstein, Fractionally-spaced equalization: an improved digital transversal equalizer, Bell System Technical Journal 60(2), 1981, pages 275 to 296, the performance of the T/2 equalizer against the symbol-spaced equalizer
- J. R. Treichler, I. Fijalkow and C. R. Johnson, Fractionally spaced equalizers: how long should they really be?, IEEE Signal Processing Magazine 13(3), 1996, pages 65 to 81, the length of a fractionally spaced equalizer
- John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Section 9.4-4 (fractionally spaced equalizers)
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 SDKX4V Edit this page History Report an error Markdown