Algorithmadvanced
Moose frequency offset estimator
Also called repeated-symbol CFO estimator.
Estimates the OFDM carrier frequency offset from the phase change between two repeated symbols, in the frequency domain. It is the maximum likelihood estimate for white noise.
- Time
- O(N log N) worst
- Space
- O(N) extra
- Where
- N = the number of subcarriers
- Model
- Real RAM
- Properties
- data aideddeterministicexact without noisemaximum likelihood
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Paul H. Moose, 1994
The Moose estimator finds the carrier frequency offset of an OFDM receiver from a training block that the transmitter sends twice. A carrier offset of subcarrier spacings turns every sample by , so the second copy, which starts samples later, arrives turned by the angle relative to the first. The receiver takes the DFT of both copies, multiplies each subcarrier of the second copy by the conjugate of the same subcarrier of the first, adds up the products into , and returns . The offset also causes inter-carrier interference, but the interference is the same in both copies apart from the factor , so the estimate is exact without noise even though each DFT output is disturbed. Moose showed that this is the maximum likelihood estimate in white Gaussian noise. It is a data-aided method for frequency offset estimation, and the timing must be known. The page uses for the imaginary unit and the unitary DFT pair of the OFDM page.
In plain words
The sender transmits the same block twice. If the receiver's oscillator is slightly off, every sample turns a little, and the turn builds up over time. So the second copy looks exactly like the first, only turned by an angle that grows with the offset and with the time between the copies. The receiver compares each part of the second copy with the same part of the first, measures the turn, and adds all the comparisons together, so strong parts count more than weak ones. The angle of the total is the turn, and the turn divided by the time between the copies is the frequency offset.
The problem
The input is two windows of received samples, and , the second starting samples after the first, where the transmitter sent the same block in both, each preceded by a cyclic prefix that covers the channel (with the first copy serves as the prefix of the second). The model is with an unknown channel , an unknown offset and white noise . Estimate , given .
The algorithm
MOOSE(y1, y2, G)- 1
Y1 ← F y1; Y2 ← F y2 ▷ DFT of both copies - 2
C ← Σ_k conj(Y1[k]) Y2[k] - 3
return angle(C) N / (2π (N + G))
Line L1 takes the DFT of the two windows. Line L2 forms the correlation. Each product is without noise, so all products have the same angle, and the sum weights each subcarrier by its power. Line L3 turns the angle into an offset: the second copy is samples later, and an offset of one spacing turns one sample by . By the Plancherel identity, also equals , so a receiver can skip line L1 and correlate in the time domain; the implementation offers both.
Example
Take and , with a prefix of 2 samples before each copy, random 4-QAM values on the subcarriers (seed 7), the channel , and noise with per sample. The true angle is rad.
| angle (rad) | offset from this alone | ||||
|---|---|---|---|---|---|
| 0 | 1.174 | 0.149 | |||
| 1 | 1.342 | 0.171 | |||
| 2 | 1.393 | 0.177 | |||
| 3 | 0.301 | 0.038 | |||
| 4 | 1.347 | 0.171 | |||
| 5 | 1.463 | 0.186 | |||
| 6 | 1.362 | 0.173 | |||
| 7 | 1.343 | 0.171 |
Line L2 gives with the angle rad, and line L3 returns , an error of . Subcarrier 3 is weak, its product is small, and its bad angle has little weight in the sum; the plain mean of the eight offsets in the last column is , a larger error.
Correctness
Claim. Without noise, if the prefixes cover the channel and , the algorithm returns exactly. With white Gaussian noise and the transmitted block unknown, it is the joint maximum likelihood estimate of the offset. Both are theorems in the model above.
Key invariant. Without noise, sample by sample, because the channel output of each copy depends only on that copy and its prefix. The DFT is linear, so on every subcarrier, including the inter-carrier interference.
Then , whose angle is . For the likelihood, the best block for a fixed is the midpoint of and , and what remains to maximize is . At a high SNR, the variance is for a block of energy , a closed form for a linearized phase error. The full proof is below.
Proof: The Moose estimate is exact without noise and is the maximum likelihood estimate for two repeated symbols in white noisefull
Notation. is the DFT size, the imaginary unit, and the unitary DFT, . The transmitter sends one block of samples twice; the second copy starts samples after the first. The channel has taps, and the first copy is preceded by at least samples that repeat its tail, as a cyclic prefix does. If , the second copy is preceded by the end of the first copy, which is its own tail; if , each copy has its own prefix of samples. The receiver sees with the offset in subcarrier spacings and independent . The windows are and , where is the start of the first copy. Lines L1 to L3 compute , and . Let .
Lemma 1 (the two windows differ by one phase). Without noise, for .
Proof. Let . The sample uses for , and uses . For both are . For , the first is a prefix sample, , and the second is either the tail of the first copy () or a sample of the second prefix (), which is also , because is not longer than the part that repeats the tail. So , and the offset factors differ by .
Lemma 2 (time or frequency domain). , and without noise.
Proof. The first is the Plancherel identity for the unitary , . The second is the linearity of applied to Lemma 1.
The inter-carrier interference that the offset causes inside each window is the same in both windows up to the factor , so it does not disturb the relation .
Theorem 1 (exact without noise). If and , the algorithm returns exactly.
Proof. By Lemma 2, with a positive sum, so modulo . The bound on gives , so the principal angle is itself, and line L3 returns .
Theorem 2 (maximum likelihood). Model the windows as and , with unknown and , independent white Gaussian noise. The joint maximum likelihood estimate of has , so of line L3 is the maximum likelihood estimate of in the range of Theorem 1.
Proof. The unitary keeps white Gaussian noise white with the same variance, so the model in the frequency domain follows from Lemma 2. The log-likelihood is a constant minus . For a fixed , each term is smallest at , the midpoint of and , and the smallest value is . Expanding,
Only the last term depends on , so the estimate maximizes , which gives . The map from to is one to one on the range, so the estimate of is also the maximum likelihood estimate.
The variance (a closed form at high SNR). Let without noise, so with three uncorrelated zero-mean noise sums of variances , and . Linearizing the angle, , and has half the variance of , so
With , and , this is , which is for at 10 dB. The tests measure it within 15 percent.
Complexity
Line L1 is two FFTs, time, and line L2 is . The correlation in the time domain needs only time. Either way the extra space is for the two windows in the real RAM.
Properties
- Range. : for two copies back to back and for . A larger offset wraps, so is read as for , as the tests check.
- Variance. For , close to at a high SNR, which is for at 10 dB. A larger lowers the variance by the factor but shrinks the range by .
- Robust to the channel. The channel only changes the weights , not the angle, so no channel estimate is needed.
- Weighting. Strong subcarriers count more than weak ones, as the maximum likelihood estimate requires; averaging the angles of single subcarriers is worse, as in the example.
- Needs the timing. The windows must lie on the copies, inside the part free of interference from earlier symbols.
Variants and improvements
- Repetition inside one symbol. Schmidl-Cox synchronization uses a symbol with two equal halves, samples apart, which doubles the range to and also gives the timing, at a larger variance.
- More copies. With short repetitions, the correlations at lags copies can be combined, trading range and variance; the short training field of IEEE 802.11a repeats a block of 16 samples ten times.
- Integer part. For offsets beyond the range, a second step searches the integer shift of the subcarriers against a known pattern, as Schmidl and Cox do with their second training symbol.
- Blind estimation. Without training, the van de Beek estimator uses the cyclic prefix as a short repetition, with a larger variance.
When to use it
Use the Moose estimator when the transmitter can send a repeated training block and the timing is known, for example as the fine step after a coarse search, or when the offset is known to be below half a spacing. For the same SNR, it has a smaller variance than Schmidl-Cox with half symbols or van de Beek with the prefix, because it correlates more samples over a longer lag. For a large initial offset, start with Schmidl-Cox synchronization or a short repeated preamble, and for a stream without training use the van de Beek estimator.
Pitfalls
- The wrong scale in line L3. The angle covers the full distance between the copies, so line L3 must multiply by . Dividing by alone is correct only for .
- Conjugating the wrong copy. Line L2 must use . With the sign of the estimate flips.
- Windows not one copy apart. Line L1 must take exactly samples after , and both inside the copies. A window that starts in the wrong place sees different data in the two copies, and the products no longer share one angle.
- Averaging angles. Line L2 must add the complex products before line L3 takes the angle. Taking the angle of each product first and averaging gives weak subcarriers too much weight, and it breaks when the angles are near .
- Ignoring the range. An offset outside wraps in line L3 with no warning. A coarse estimate with a wider range must come first.
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)
moose_frequency_offset_estimator.py 44 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/moose-frequency-offset-estimator/. The authors are listed in prov/6JQ8CA.jsonl.
"""Moose's estimator of the carrier frequency offset from two copies of one OFDM symbol.
The transmitter sends the same N samples twice. The second copy starts
N + G samples after the first (G = 0 if the copies follow each other, G = the
prefix length if each copy has its own prefix). A carrier offset epsilon, in
subcarrier spacings, turns subcarrier k of the second copy into
Y2[k] = e^(j 2 pi epsilon (N + G) / N) Y1[k] + noise. The estimate is
C = sum over k of conj(Y1[k]) Y2[k]
epsilon_hat = angle(C) N / (2 pi (N + G))
and its range is |epsilon| < N / (2 (N + G)). The page uses the unitary DFT,
so C is also sum over n of conj(y1[n]) y2[n] (Plancherel).
"""
import cmath
import math
import cbb
def correlation(y1: list[complex], y2: list[complex]) -> complex:
"""C = sum over k of conj(Y1[k]) Y2[k], from the two received copies in the time domain."""
if len(y1) != len(y2) or not y1:
raise ValueError("the two copies must have the same nonzero length")
f1, f2 = cbb.udft(y1), cbb.udft(y2) # @line L1
return sum(a.conjugate() * b for a, b in zip(f1, f2)) # @line L2
def estimate(y1: list[complex], y2: list[complex], gap: int = 0) -> float:
"""epsilon_hat in subcarrier spacings. gap is G, the number of samples between the copies."""
n = len(y1)
c = correlation(y1, y2)
return cmath.phase(c) * n / (2 * math.pi * (n + gap)) # @line L3
def estimate_time_domain(y1: list[complex], y2: list[complex], gap: int = 0) -> float:
"""The same estimate with C = sum over n of conj(y1[n]) y2[n], with no DFT."""
n = len(y1)
c = sum(a.conjugate() * b for a, b in zip(y1, y2))
return cmath.phase(c) * n / (2 * math.pi * (n + gap))
test_moose_frequency_offset_estimator.py 93 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/moose-frequency-offset-estimator/. The authors are listed in prov/6JQ8CA.jsonl.
import cmath
import math
import random
import cbb
from moose_frequency_offset_estimator import correlation, estimate, estimate_time_domain
S = 1 / math.sqrt(2)
def qpsk(rng: random.Random, n: int) -> list[complex]:
return [complex(rng.choice((S, -S)), rng.choice((S, -S))) for _ in range(n)]
def apply_cfo(r: list[complex], eps: float, n: int) -> list[complex]:
return [x * cmath.exp(2j * math.pi * eps * i / n) for i, x in enumerate(r)]
def two_copies(rng: random.Random, n: int, ncp: int, each_prefix: bool) -> tuple[list[complex], int, int]:
"""The repeated symbol: one prefix then two copies (G = 0), or a prefix before each copy (G = ncp).
Returns the samples, the start of the first copy and G.
"""
x = cbb.uidft(qpsk(rng, n))
pre = x[n - ncp:]
if each_prefix:
return pre + x + pre + x, ncp, ncp
return pre + x + x, ncp, 0
def test_plancherel_gives_the_same_correlation() -> None:
rng = random.Random(1)
a = [cbb.cn(rng, 1.0) for _ in range(32)]
b = [cbb.cn(rng, 1.0) for _ in range(32)]
c = sum(x.conjugate() * y for x, y in zip(a, b))
assert abs(correlation(a, b) - c) < 1e-9
assert abs(estimate(a, b, 5) - estimate_time_domain(a, b, 5)) < 1e-12
def test_exact_without_noise_through_a_multipath_channel() -> None:
rng = random.Random(2)
n, ncp, h = 32, 4, [0.8, -0.4j, 0.3, 0.2 + 0.1j]
for each_prefix in (False, True):
for eps in (0.0, 0.07, -0.33, 0.39):
s, start, gap = two_copies(rng, n, ncp, each_prefix)
r = apply_cfo(cbb.conv(s, h), eps, n)
y1 = r[start:start + n]
y2 = r[start + n + gap:start + 2 * n + gap]
assert abs(estimate(y1, y2, gap) - eps) < 1e-9
def test_range_shrinks_with_the_gap() -> None:
# G = 0: range 1/2, so 0.6 reads as -0.4. G = N / 4: range N / (2 (N + G)) = 0.4, so 0.45 reads as -0.35.
rng = random.Random(3)
n = 32
for gap, eps, seen in ((0, 0.6, -0.4), (8, 0.45, -0.35)):
x = cbb.uidft(qpsk(rng, n))
r = apply_cfo(x + [0j] * gap + x, eps, n)
assert abs(estimate(r[:n], r[n + gap:], gap) - seen) < 1e-9
def test_matches_a_grid_search_of_the_likelihood() -> None:
# Two copies Y2 = e^(j 2 pi eps) Y1 in white Gaussian noise: the ML estimate maximizes
# Re(e^(-j 2 pi eps) C). A grid of 20001 points on [-1/2, 1/2] finds the same value.
rng = random.Random(4)
n = 16
x = cbb.uidft(qpsk(rng, n))
r = cbb.awgn(rng, apply_cfo(x + x, 0.21, n), 0.3)
y1, y2 = r[:n], r[n:]
c = correlation(y1, y2)
grid = [-0.5 + i / 20000 for i in range(20001)]
best = max(grid, key=lambda e: (cmath.exp(-2j * math.pi * e) * c).real)
assert abs(best - estimate(y1, y2)) <= 1 / 40000 + 1e-12
def test_variance_at_10_db() -> None:
# Unit-energy 4-QAM on N = 16 subcarriers, so each copy has energy N. With SNR = 10 dB per sample,
# var(eps_hat) is about (1 / (4 pi^2 N SNR)) (1 + 1 / (2 SNR)) = 1.6623e-4. 2000 trials, seed 5.
rng = random.Random(5)
n, n0, eps = 16, 0.1, 0.1
expect = (1 + n0 / 2) * n0 / (4 * math.pi ** 2 * n)
assert abs(expect - 1.6623e-4) < 1e-8
x = cbb.uidft(qpsk(rng, n))
s = apply_cfo(x + x, eps, n)
acc = 0.0
trials = 2000
for _ in range(trials):
r = cbb.awgn(rng, s, n0)
acc += (estimate(r[:n], r[n:]) - eps) ** 2
assert 0.85 < acc / trials / expect < 1.15
History
Paul H. Moose, at the Naval Postgraduate School, published the estimator in IEEE Transactions on Communications in 1994. He showed that the offset can be estimated after the DFT from a repeated symbol, derived the maximum likelihood estimate, and studied its accuracy. With whole symbols, the range is limited to half a subcarrier spacing. Schmidl and Cox later moved the repetition inside one symbol to widen the range and to get the timing from the same correlation, and the repeated preamble became the usual training for OFDM packet systems.
References
- P. H. Moose, A technique for orthogonal frequency division multiplexing frequency offset correction, IEEE Transactions on Communications 42(10), 1994, pages 2908 to 2914 (the repeated symbol, the maximum likelihood estimate of the offset from the phase of the correlation after the DFT, and its range)
- T. M. Schmidl and D. C. Cox, Robust frequency and timing synchronization for OFDM, IEEE Transactions on Communications 45(12), 1997, pages 1613 to 1621 (the repetition inside one symbol, which widens the range of the offset estimate)
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 6JQ8CA Edit this page History Report an error Markdown