Algorithmadvanced
MMSE turbo equalizer with soft interference cancellation
Also called Tuchler-Koetter-Singer equalizer, SISO MMSE equalizer.
A linear MMSE equalizer that uses decoder priors: it subtracts the soft symbol means and outputs extrinsic LLRs. Exact form O(W^3) per symbol for a window W; a fixed-filter form is far cheaper.
- Solves
- Channel equalization
- Time
- O(K W^3) worst
- Space
- O(W^2) extra
- Where
- K = the number of symbols; L = the number of channel taps; W = the window length N1 + N2 + 1
- Model
- Real RAM
- Properties
- deterministicnot exact mapextrinsic outputneeds channelneeds noise levelsoft inputsoft output
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Michael Tüchler, Ralf Koetter, Andrew C. Singer, 2002
The MMSE turbo equalizer with soft interference cancellation is the low-cost soft-in soft-out equalizer of turbo equalization. It is a linear MMSE equalizer that also uses prior LLRs from the decoder. For each symbol , it turns the priors of the other symbols into soft means and variances, subtracts the mean interference from the received window, and filters the rest with the MMSE filter for those variances. It then turns the filter output into an extrinsic LLR with a Gaussian model. The difference from the turbo equalization page is the scope. That page is the loop: equalizer, deinterleaver, decoder, interleaver, and back. This page is one equalizer for that loop, which replaces the BCJR equalizer. The BCJR equalizer costs per symbol for BPSK and taps. This one costs per symbol in its exact form, for a window of samples, and much less in its fixed-filter form.
In plain words
A coded signal passes through a channel with echoes. A decoder already has a guess about each transmitted bit, with a level of confidence. To estimate one symbol, the equalizer uses the guesses for its neighbours. It removes their expected echoes from the received samples, and it trusts this more where the decoder is more confident. What is left is mostly the wanted symbol plus noise and the echoes of the uncertain neighbours. A linear filter, tuned to that remaining uncertainty, then gives the best linear estimate of the symbol. The equalizer ignores the decoder's guess about the symbol itself, so that it returns only new information. This new information goes back to the decoder, and the two repeat.
The problem
The input is a block of BPSK symbols sent through a real channel that the receiver knows:
The receiver also has a prior LLR for each symbol, from the decoder. The prior gives the soft mean and variance
The output is an extrinsic LLR for each , which must not depend on . A linear MMSE estimate of from a window of samples is wanted, not the exact posterior, which the BCJR algorithm gives at exponential cost.
For symbol , the window is , with samples and . It equals for the symbols and the matrix with . Column of belongs to ; call it . Symbols outside the block are known zeros, and samples outside it are zero.
The algorithm
SISO-MMSE(y, h, L_a, σ², N1, N2)- 1
x̄_k ← tanh(L_a(x_k)/2), v_k ← 1 - x̄_k² for all k - 2
for n ← 0 to K - 1 do - 3
Y ← (y[n-N2], ..., y[n+N1]); X̄, V ← means and diagonal of variances of the window symbols - 4
C ← H V Hᵀ + σ² I + (1 - v_n) s sᵀ ▷ the covariance with x_n unknown - 5
f ← C⁻¹ s - 6
x̂ ← fᵀ (Y - H X̄ + x̄_n s) ▷ cancel the soft interference - 7
μ ← sᵀ f - 8
L_e(x_n) ← 2 x̂ / (1 - μ) - 9
return L_e
Line L1 converts the priors to soft symbols. A prior of 0 gives mean 0 and variance 1, and a very large prior gives mean and variance 0. Line L3 reads the window. Line L4 is the covariance of when has mean 0 and variance 1 and every other symbol has its prior mean and variance: the term replaces by 1 in . Line L5 is the MMSE filter for that covariance. Line L6 subtracts the mean of under the same model, , and filters the rest. Line L7 is the gain of the filter on . Line L8 is the LLR of under the model .
The fixed-filter form replaces in line L4 by , with the mean of all , and runs lines L4 and L5 once per block. Then only lines L6 to L8 run per symbol. The code has both forms; the flag approx selects the second.
Example
One symbol by hand. Take , , , five symbols with priors and the samples . For , line L1 gives and for to . The window is , and
Line L5 gives . The cancelled window is , because . Then , and . The five outputs are .
Better priors, fewer errors. On the Proakis B channel with , , symbols (seed 7), the priors are drawn as consistent Gaussian LLRs, (seed 8). The table gives the error rate of the sign of alone. This is a measurement.
| prior variance | 0 | 1 | 4 | 16 | perfect |
|---|---|---|---|---|---|
| exact form | 0.1325 | 0.1150 | 0.0778 | 0.0278 | 0.0220 |
| fixed-filter form | 0.1325 | 0.1155 | 0.0875 | 0.0333 | 0.0220 |
The matched filter bound is . With perfect priors, all the interference is removed, and both forms reach the bound. With no priors, both forms are the plain MMSE equalizer. In between, the exact form is better, because it uses the variance of each neighbour.
Correctness
Claim 1 (the linear MMSE estimate). Model as mean 0 and variance 1, and every other symbol in the window as independent with mean and variance . Then of line L6 is the linear MMSE estimate of from , and of line L7 is its covariance with . This is a theorem. Under the model, , and , and the linear MMSE estimate is . The test enumerates all 32 symbol patterns of a small case, builds the mean and the covariance from them, and matches the code to .
Claim 2 (extrinsic). does not depend on . This is a theorem: enters line L4 through , in which the terms cancel, and line L6 through , in which the terms cancel.
Claim 3 (the Gaussian LLR). For each value of , and , with . These moments are a theorem. Line L8 is the exact LLR of a Gaussian with these moments, . The Gaussian shape is a heuristic: is a sum of noise and residual symbols, and it is only close to Gaussian. So is not the true extrinsic LLR, and the equalizer is not the MAP equalizer.
Special cases, as closed forms. With all priors 0, , and , the MMSE linear equalizer. With perfect priors, , and , the matched filter after exact cancellation, which is the true LLR for that case. The proofs folder has the details.
Proof: The SISO MMSE equalizer computes the linear MMSE estimate under the prior model, its output is extrinsic, and its LLR is exact for the Gaussian model of the estimatefull
Setting. For symbol , the window is , with of size , independent of , and . Column of is , and . The prior model says: the entries of are independent; has mean 0 and variance 1; every other entry has mean and variance , from line L1, or mean 0 and variance 0 if it lies outside the block. Let be with entry set to 0, and be with entry set to 1.
Lemma 1 (the moments of the window). Under , , , which is the matrix of line L4, and .
Proof. , and . The entries of are independent, so , and is independent of , so . Now , so , which is line L4. Last, .
Theorem 1 (linear MMSE). Among all estimates , the one with the least is with , which is line L6.
Proof. , so is invertible. Write the error as . Its mean square is . The first term is 0 for , since . The second is , a strictly convex quadratic in with gradient , which is zero only at . So , and by Lemma 1, .
Theorem 2 (extrinsic). does not depend on .
Proof. enters only through and . By Lemma 1, , and does not contain . The vector , and does not contain . So , , and do not depend on .
Lemma 2 (). Let , where is with entry set to 0. Then , and with , .
Proof. . By the Sherman-Morrison formula, , so .
Theorem 3 (the conditional moments). Under and given , and .
Proof. Given , , where is with entry set to 0. The last two terms have mean 0 and covariance . So and , using .
Theorem 4 (the LLR of the Gaussian model). If is modeled as and , then , which is line L8.
Proof. The two Gaussians have the same variance , so the log ratio is . With , is , so this is the LLR in the sign convention .
What is not proved. Theorem 3 gives the true first two moments under , but given is a mixture over the other symbols plus Gaussian noise. It is Gaussian only when no residual symbol variance reaches the output, that is, when on the support of . Then is the true extrinsic LLR of . Otherwise the Gaussian model is a heuristic. The prior model is also a heuristic inside a turbo loop: the decoder outputs are not independent, and they are not exact. So the equalizer is not the MAP equalizer.
Two closed forms. If every prior is 0, then , and , the MMSE linear equalizer for the delay . If every prior is perfect, then , , , , and . Here given is exactly Gaussian, so this is the true LLR. The tests check both forms and an enumeration of Theorem 1 and Theorem 3 to .
Complexity
In the exact form, line L4 builds a matrix in operations, and line L5 solves it in . Since , symbols cost time in the real RAM and extra space. The window moves by one sample per symbol, so shares a block with the previous one, and a bordering update of the inverse brings the cost to per symbol; the code does not do this. The fixed-filter form solves once, in , and then costs per symbol if is computed once; the code computes line L6 directly, in . The BCJR equalizer, for comparison, costs per symbol for BPSK, one step per trellis edge, so the MMSE equalizer pays off for long channels and large alphabets.
Properties
- Soft in, soft out, extrinsic. The output can go back to a decoder without the prior of the same symbol.
- It reduces to known equalizers. With no priors, it is the linear MMSE equalizer. With perfect priors, it is the matched filter after cancellation, which reaches the matched filter bound.
- Not MAP. It is linear in and its LLR uses a Gaussian model, so in the first iteration it is worse than the BCJR equalizer on a hard channel such as Proakis B.
- Needs the channel and the noise level. Both enter ; an estimate is used in practice.
- The fixed-filter form is exact for equal variances. When all are equal, in the interior of the block, and the two forms agree there to rounding. The test checks this.
Variants and improvements
- Fixed-filter form. One filter per block from the mean variance, as above. It trades some performance for a large drop in cost.
- Frequency-domain form. With a cyclic prefix, the fixed filter becomes one division per frequency, as in frequency domain equalization.
- Decision feedback. Feed back the soft means of past symbols in a decision feedback structure.
- Expectation propagation. EP detection also uses Gaussian models of the symbols, but it refines the means and variances from the equalizer's own posterior, not only from the decoder priors.
- MIMO and CDMA. The same steps with a MIMO channel matrix give the soft MMSE MIMO detector; Wang and Poor (1999) used them for coded CDMA.
When to use it
Use it as the equalizer of a turbo receiver when the BCJR equalizer is too costly: long channels, large alphabets, or MIMO. Use the fixed-filter or frequency-domain form when the cost must be close to that of a plain MMSE equalizer. For short channels with BPSK, the BCJR equalizer is cheap and better, especially in the first iteration.
Pitfalls
- Feeding back posterior LLRs into line L1. The prior must be the extrinsic output of the decoder. Posteriors count the equalizer's own information twice, and the loop becomes overconfident.
- Leaving with its prior in line L4 or line L6. Then the output is not extrinsic, and Claim 2 fails.
- Overflow in line L1. Use , not , for large .
- A noise variance that is too small in line L4. With perfect priors, tends to as , and the LLRs become huge. Do not set to 0.
- Edge effects. At the ends of the block, the window reaches outside. Treat missing symbols as known zeros and missing samples as zero, as in the code, or use a terminated block.
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)
soft_interference_cancellation_equalizer.py 89 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/soft-interference-cancellation-equalizer/. The authors are listed in prov/G8QTJ4.jsonl.
"""The MMSE turbo equalizer with soft interference cancellation (Tuchler, Koetter and Singer).
BPSK symbols x_k = 1 - 2 b_k in {+1, -1} pass a real channel h of L taps:
y_m = sum_l h_l x_(m-l) + w_m, w_m ~ N(0, sigma2), for m = 0, ..., K + L - 2.
The prior LLRs La_k = ln P(b_k = 0) / P(b_k = 1) give the soft symbols
xbar_k = tanh(La_k / 2) with variances v_k = 1 - xbar_k^2.
For symbol n, the window Y = (y_(n-N2), ..., y_(n+N1)) of W = N1 + N2 + 1
samples is H X + noise, with X = (x_(n-N2-L+1), ..., x_(n+N1)) and
H[i][j] = h[i - j + L - 1]. The column of H for x_n is s, with s_i = h[i - N2].
The estimate treats x_n as unknown (mean 0, variance 1), so that its own
prior does not enter, and uses the priors of all other symbols:
C = H V H^T + sigma2 I + (1 - v_n) s s^T, f = C^-1 s,
xhat = f^T (Y - H xbar + xbar_n s), mu = s^T f,
Le_n = 2 xhat / (1 - mu).
The approximate form replaces V by the average variance vbar times I, so f
is computed once per block.
Samples outside 0..K+L-2 are 0, and symbols outside 0..K-1 are known zeros
(mean 0, variance 0); then such samples carry no signal and get weight 0.
"""
import math
import cbb
def soft_symbols(la: list[float]) -> tuple[list[float], list[float]]:
"""The means tanh(La / 2) and variances 1 - mean^2 of BPSK symbols with prior LLRs La."""
xbar = [math.tanh(v / 2.0) for v in la]
return xbar, [1.0 - m * m for m in xbar]
def window_matrix(h: list[float], w: int) -> list[list[float]]:
"""The W by (W + L - 1) matrix H with H[i][j] = h[i - j + L - 1]."""
taps = len(h)
return [[float(h[i - j + taps - 1]) if 0 <= i - j + taps - 1 < taps else 0.0 for j in range(w + taps - 1)] for i in range(w)]
def _real_solve(a: list[list[float]], b: list[float]) -> list[float]:
return [v.real for v in cbb.solve(a, b)]
def siso_equalize(
y: list[float], h: list[float], la: list[float], sigma2: float, n1: int, n2: int, approx: bool = False
) -> list[float]:
"""Extrinsic LLRs Le_n for n = 0, ..., K-1, where K = len(la) and len(y) = K + L - 1."""
taps, k = len(h), len(la)
if taps < 1 or sigma2 <= 0 or n1 < taps - 1 or n2 < 0 or len(y) != k + taps - 1:
raise ValueError("need L >= 1, sigma2 > 0, N1 >= L - 1, N2 >= 0 and len(y) = K + L - 1")
w = n1 + n2 + 1
hm = window_matrix(h, w)
j0 = n2 + taps - 1
s = [hm[i][j0] for i in range(w)]
xbar, var = soft_symbols(la) # @line L1
def sym(t: int) -> tuple[float, float]:
return (xbar[t], var[t]) if 0 <= t < k else (0.0, 0.0)
def sample(m: int) -> float:
return float(y[m]) if 0 <= m < len(y) else 0.0
f_fixed = None
if approx:
vbar = sum(var) / k
c = [[vbar * sum(hm[i][j] * hm[r][j] for j in range(w + taps - 1)) + (sigma2 if i == r else 0.0) + (1 - vbar) * s[i] * s[r] for r in range(w)] for i in range(w)] # @line L4
f_fixed = _real_solve(c, s) # @line L5
out = []
for n in range(k): # @line L2
yw = [sample(n - n2 + i) for i in range(w)] # @line L3
xs = [sym(n - n2 - taps + 1 + j) for j in range(w + taps - 1)] # @line L3
mx = [m for m, _ in xs] # @line L3
if approx:
f = f_fixed
else:
vn = xs[j0][1]
c = [
[sum(hm[i][j] * xs[j][1] * hm[r][j] for j in range(w + taps - 1)) + (sigma2 if i == r else 0.0) + (1 - vn) * s[i] * s[r] for r in range(w)]
for i in range(w)
] # @line L4
f = _real_solve(c, s) # @line L5
resid = [yw[i] - sum(hm[i][j] * mx[j] for j in range(w + taps - 1)) + mx[j0] * s[i] for i in range(w)] # @line L6
xhat = sum(fi * ri for fi, ri in zip(f, resid)) # @line L6
mu = sum(si * fi for si, fi in zip(s, f)) # @line L7
out.append(2.0 * xhat / (1.0 - mu)) # @line L8
return out # @line L9
test_soft_interference_cancellation_equalizer.py 134 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/soft-interference-cancellation-equalizer/. The authors are listed in prov/G8QTJ4.jsonl.
import itertools
import math
import random
import pytest
import cbb
from soft_interference_cancellation_equalizer import siso_equalize, soft_symbols, window_matrix
PROAKIS_B = [0.407, 0.815, 0.407]
def received(rng, x, h, sigma):
return [v.real + rng.gauss(0.0, sigma) for v in cbb.conv(x, h)]
def test_no_priors_give_the_mmse_linear_equalizer():
rng = random.Random(3)
h, s2, n1, n2, k = [1.0, 0.5], 0.2, 2, 2, 12
x = [rng.choice((-1, 1)) for _ in range(k)]
y = received(rng, x, h, math.sqrt(s2))
le = siso_equalize(y, h, [0.0] * k, s2, n1, n2)
w = n1 + n2 + 1
hm = window_matrix(h, w)
s = [row[n2 + len(h) - 1] for row in hm]
r = [[sum(a * b for a, b in zip(hm[i], hm[q])) + (s2 if i == q else 0.0) for q in range(w)] for i in range(w)]
f = [v.real for v in cbb.solve(r, s)]
mu = sum(a * b for a, b in zip(f, s))
for n in range(n2 + len(h) - 1, k - n1):
z = sum(f[i] * y[n - n2 + i] for i in range(w))
assert abs(le[n] - 2 * z / (1 - mu)) < 1e-9
def test_perfect_priors_give_the_matched_filter_after_cancellation():
rng = random.Random(4)
h, s2, n1, n2, k = PROAKIS_B, 0.3, 3, 2, 10
x = [rng.choice((-1, 1)) for _ in range(k)]
y = received(rng, x, h, math.sqrt(s2))
le = siso_equalize(y, h, [50.0 * v for v in x], s2, n1, n2)
for n in range(k):
clean = cbb.conv([v if t != n else 0 for t, v in enumerate(x)], h)
mf = sum(h[l] * (y[n + l] - clean[n + l].real) for l in range(len(h)))
assert abs(le[n] - 2 * mf / s2) < 1e-9
def test_lmmse_by_enumeration_and_the_gaussian_moments():
h, s2, n1, n2 = [0.9, -0.5], 0.4, 1, 1
la = [0.7, -1.3, 2.1, 0.4, -0.2]
y = [0.3, -1.1, 0.8, 0.5, -0.4, 0.2]
n = 2
le = siso_equalize(y, h, la, s2, n1, n2)
xbar, _ = soft_symbols(la)
rows = range(n - n2, n + n1 + 1)
p1 = [(1 + m) / 2 for m in xbar]
p1[n] = 0.5
my = [0.0] * len(rows)
cyy = [[0.0] * len(rows) for _ in rows]
cxy = [0.0] * len(rows)
for xs in itertools.product((1, -1), repeat=len(la)):
p = math.prod(p1[t] if xs[t] == 1 else 1 - p1[t] for t in range(len(la)))
clean = [v.real for v in cbb.conv(list(xs), h)]
vals = [clean[m] for m in rows]
for i, a in enumerate(vals):
my[i] += p * a
cxy[i] += p * xs[n] * a
for q, b in enumerate(vals):
cyy[i][q] += p * a * b
cyy = [[cyy[i][q] - my[i] * my[q] + (s2 if i == q else 0.0) for q in range(len(rows))] for i in range(len(rows))]
g = [v.real for v in cbb.solve(cyy, cxy)]
xhat = sum(gi * (y[m] - mi) for gi, m, mi in zip(g, rows, my))
mu = sum(gi * ci for gi, ci in zip(g, cxy))
assert abs(le[n] - 2 * xhat / (1 - mu)) < 1e-9
for sign in (1, -1):
mean = 0.0
second = 0.0
for xs in itertools.product((1, -1), repeat=len(la)):
if xs[n] != sign:
continue
p = 2 * math.prod(p1[t] if xs[t] == 1 else 1 - p1[t] for t in range(len(la)))
clean = [v.real for v in cbb.conv(list(xs), h)]
z = sum(gi * (clean[m] - mi) for gi, m, mi in zip(g, rows, my))
mean += p * z
second += p * z * z
var = second - mean * mean + s2 * sum(gi * gi for gi in g)
assert abs(mean - sign * mu) < 1e-9
assert abs(var - (mu - mu * mu)) < 1e-9
def test_extrinsic_output_ignores_its_own_prior():
rng = random.Random(5)
h, s2, k = PROAKIS_B, 0.25, 9
la = [rng.uniform(-3, 3) for _ in range(k)]
y = [rng.gauss(0, 1) for _ in range(k + len(h) - 1)]
base = siso_equalize(y, h, la, s2, 3, 3)
for n in range(k):
changed = list(la)
changed[n] = -changed[n] + 4.0
assert abs(siso_equalize(y, h, changed, s2, 3, 3)[n] - base[n]) < 1e-9
def test_approximate_form_is_exact_when_all_variances_are_equal():
rng = random.Random(6)
h, s2, n1, n2, k = PROAKIS_B, 0.25, 3, 3, 14
la = [rng.choice((-1.5, 1.5)) for _ in range(k)]
y = [rng.gauss(0, 1) for _ in range(k + len(h) - 1)]
exact = siso_equalize(y, h, la, s2, n1, n2)
approx = siso_equalize(y, h, la, s2, n1, n2, approx=True)
for n in range(n2 + len(h) - 1, k - n1):
assert abs(exact[n] - approx[n]) < 1e-9
def test_bit_error_rate_with_perfect_priors_matches_the_matched_filter_bound():
rng = random.Random(1)
k, sigma = 10000, 0.5
x = [rng.choice((-1, 1)) for _ in range(k)]
y = received(rng, x, PROAKIS_B, sigma)
le = siso_equalize(y, PROAKIS_B, [50.0 * v for v in x], sigma * sigma, 2, 2, approx=True)
errors = sum((l < 0) != (v < 0) for l, v in zip(le, x))
p = cbb.qfunc(math.sqrt(sum(v * v for v in PROAKIS_B)) / sigma)
assert k * p >= 100
lo, hi = cbb.wilson(errors, k)
assert lo <= p <= hi
def test_bad_input():
with pytest.raises(ValueError):
siso_equalize([0.0] * 4, [1.0, 0.5], [0.0] * 3, 0.0, 1, 1)
with pytest.raises(ValueError):
siso_equalize([0.0] * 4, [1.0, 0.5], [0.0] * 3, 0.1, 0, 1)
with pytest.raises(ValueError):
siso_equalize([0.0] * 3, [1.0, 0.5], [0.0] * 3, 0.1, 1, 1)
History
Wang and Poor (1999) combined soft interference cancellation with an MMSE filter in an iterative receiver for coded CDMA. Tüchler, Koetter and Singer (2002) and Tüchler, Singer and Koetter (2002) worked out the MMSE equalizer with a priori information for turbo equalization, with exact and approximate forms, and showed that it comes close to the MAP equalizer at much lower cost. Koetter, Singer and Tüchler (2004) gave a tutorial on the method.
References
- Michael Tüchler, Ralf Koetter and Andrew C. Singer, Turbo equalization: principles and new results, IEEE Transactions on Communications 50(5), 2002, pages 754 to 767, the linear MMSE equalizer with a priori information inside the turbo loop, its exact and approximate forms, and the comparison with the MAP equalizer
- Michael Tüchler, Andrew C. Singer and Ralf Koetter, Minimum mean squared error equalization using a priori information, IEEE Transactions on Signal Processing 50(3), 2002, pages 673 to 683, the MMSE filter whose coefficients are recomputed for each symbol from the prior means and variances
- Ralf Koetter, Andrew C. Singer and Michael Tüchler, Turbo equalization, IEEE Signal Processing Magazine 21(1), 2004, pages 67 to 80, a tutorial on turbo equalization with the MAP and the MMSE equalizers
- Xiaodong Wang and H. Vincent Poor, Iterative (turbo) soft interference cancellation and decoding for coded CDMA, IEEE Transactions on Communications 47(7), 1999, pages 1046 to 1061, soft interference cancellation with the decoder outputs, followed by an MMSE filter
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 G8QTJ4 Edit this page History Report an error Markdown