Algorithmadvanced
Rife and Boorstyn frequency estimator
Also called ML single-tone frequency estimation, periodogram peak frequency estimator.
Finds the maximum likelihood frequency of a tone in noise as the peak of the periodogram, refined by a local search.
- Time
- O(N log N + N I) worst
- Space
- O(N) extra
- Where
- I = the number of golden-section steps (about the log of 1/(N times the tolerance)); N = the number of samples
- Model
- Real RAM
- Properties
- deterministicfeedforwardmaximum likelihood
- Evidence
- Proof sketchCode in 1 languages
- Origin
- David C. Rife, Robert R. Boorstyn, 1974
The Rife and Boorstyn estimator finds the frequency of one complex tone in white Gaussian noise by maximum likelihood. With the amplitude and the phase unknown, the likelihood is largest where the periodogram is largest. So the estimator computes a zero-padded FFT for a coarse search, then refines the best grid point by a local search, here a golden-section search. It differs from the plain periodogram, which is a spectral estimate on a fixed grid: the refinement removes the grid error, which at high SNR would otherwise be far larger than the noise error. It is the reference method for frequency offset estimation. Above a threshold its variance reaches the Cramer-Rao bound , which with known data is the modified Cramer-Rao bound, and its threshold is the lowest of the common estimators, because it depends on . The Kay estimator and the Luise and Reggiannini estimator cost less but have higher thresholds or smaller ranges.
In plain words
The receiver tries many candidate frequencies. For each one, it turns the samples back by that frequency and adds them up. At the right frequency all samples point the same way, and the sum is long. At a wrong frequency they point in different directions and the sum is short. A fast transform checks a fine grid of candidates at once. The receiver then searches near the best candidate, step by step, until the sum is as long as it can be. When the noise is very strong, a random candidate far from the right one can give a longer sum, and the answer is then completely wrong.
The problem
The input is , , with unknown , and , in radians per sample, and white, . In a receiver, is the signal with the known pilot symbols removed. Output the maximum likelihood estimate .
The algorithm
RIFE-BOORSTYN(r[0..N-1], K, tol) ▷ K >= 4N, a power of two- 1
X <- FFT of r padded with zeros to K points - 2
i* <- the index i with the largest |X[i]| - 3
a <- 2 pi (i* - 1) / K; b <- 2 pi (i* + 1) / K - 4
omega <- golden-section maximizer of P(w) = |sum_t r[t] exp(-j w t)|^2 / N on [a, b], to tol - 5
return omega reduced to [-pi, pi)
Line L1 evaluates on the grid . Zero padding to makes the grid fine enough that the best grid point is in the main lobe of the signal peak. Line L4 evaluates directly, per point, about 50 times for a tolerance of . Any local search that keeps a bracket works here.
Example
, , , dB (noise seed 9), . The grid spacing is . Line L1 gives these periodogram values near the peak:
| 3 | 4 | 5 | 6 | 7 | |
|---|---|---|---|---|---|
Line L2 picks , and line L3 gives . The golden-section search ends at , where . The error is . The grid point alone would have had the error . The bound is a standard deviation of .
With , 400 random tones per point with uniform in (seed 2), the mean square error over the CRB was (measurements). An outlier is an error larger than . The last row uses the grid point of line L2 alone, with :
| SNR | dB | dB | 0 dB | 3 dB | 5 dB | 10 dB |
|---|---|---|---|---|---|---|
| MSE/CRB, RB | ||||||
| outliers in 400 | ||||||
| MSE/CRB, grid only |
The threshold is between and dB for , that is between 9 dB and 12 dB. Above it, the estimate is at the bound. Without the fine search, the grid error dominates and the ratio grows with the SNR.
Correctness
Claim. Minimizing over the complex amplitude leaves , so the ML frequency is the maximizer of (theorem). Without noise, the algorithm returns to within the tolerance (theorem). In noise it returns the global maximizer whenever the global peak is within one grid step of the best grid point and is unimodal there (theorem); that this holds above threshold is a rule, and that the variance there approaches the CRB is a closed form under assumptions.
Key steps. Without noise, , where is the Dirichlet kernel. decreases on , and it is at most outside the main lobe. With , the nearest grid point has , so it is the best one, and the bracket of line L3 stays within of , inside the main lobe, where is unimodal.
Proof: The ML frequency of a tone is the periodogram peak, and the coarse FFT search with golden-section refinement finds it exactly without noisefull
The input is , , , with an unknown complex amplitude , an unknown frequency , and white. Let and , the periodogram. Line L1 computes at the points with a zero-padded FFT, a power of two. Line L2 takes the index of the largest . Line L3 sets the interval . Line L4 runs a golden-section search for the maximum of on , and line L5 reduces the result to . Write .
Theorem 1 (the ML estimate is the periodogram peak). The maximum likelihood estimate of , with unknown, is any maximizer of over .
Proof. The log-likelihood is plus a constant. For a fixed , this is a least squares problem in , with the solution , since the vector has squared norm . The minimum is . So maximizing the likelihood over is the same as maximizing over , and .
Lemma 2 (the Dirichlet kernel). Let , with . Then is strictly decreasing on , and for .
Proof. With , , and . For , every is at most , so each term , and the terms with are positive. Hence is strictly decreasing on , from to , and there. For , , so .
Theorem 2 (exact without noise). If , the algorithm returns to within the tolerance of the golden-section search.
Proof. Without noise, with the difference taken modulo , so has its unique maximum at . Let be the grid point nearest to ; . By Lemma 2, , which is larger than every value outside the main lobe . Inside the main lobe, decreases with , so no other grid point has a larger value. So line L2 picks , up to ties that only occur at equal distance and change nothing below. The interval of line L3 is , which contains , and every point of it is within of . On it, is strictly increasing up to and strictly decreasing after it, so it is unimodal. Golden-section search on a unimodal function keeps the maximizer in its bracket and shrinks the bracket by the factor per step, so it returns to within the tolerance.
Theorem 3 (with noise). The algorithm returns the global maximizer of , that is the ML estimate, whenever (a) the global maximizer lies within of the grid point with the largest value and (b) is unimodal on that interval. Without these conditions it returns a local maximum of on the interval.
Proof. Under (b), the golden-section search converges to the maximizer of on ; under (a), that is the global maximizer. Without them, golden-section search still returns a point of its last bracket, where has a local maximum or a bracket end.
Conditions (a) and (b) hold at high SNR, because is then close to the noise-free case of Theorem 2, plus a small perturbation; they are a rule, not a theorem, at moderate SNR, and the tests check against a dense brute-force grid that the estimate is the global peak. The variance of the ML estimate tends to the Cramer-Rao bound as the SNR grows. That is a closed form under assumptions (asymptotic efficiency of ML above threshold), shown by Rife and Boorstyn and measured in the tests. Below a threshold in , a noise peak elsewhere is higher than the signal peak with a noticeable probability, and the estimate is an outlier anywhere in .
Complexity. Line L1 is an FFT of points, . Line L2 is . Line L4 needs evaluations of , each . The total is time and space.
Complexity
The FFT costs for . The golden-section search needs evaluations of , each . Space is for the padded FFT. This is more than the of the Kay and Luise and Reggiannini estimators, but small in absolute terms.
Properties
- Maximum likelihood. It is the ML estimator for one tone in white Gaussian noise, and it is asymptotically efficient.
- Lowest threshold. The threshold depends on , so long blocks work at a low per-sample SNR. In the measurement with , it is at the bound from 0 dB, where the Kay estimator is 185 times above it.
- Full range. It covers , with no reduction of range.
- Outliers below threshold. Below threshold, the errors are not larger Gaussian errors but jumps to a random frequency: 48 of 400 trials at dB.
- One tone only. Several tones or a strong interferer shift the peak or create a false one.
Variants and improvements
- Interpolation instead of search. Fit a parabola, or use the formulas of Quinn, Jacobsen or Macleod, to the three largest FFT values. This is after the FFT and close to the bound for moderate SNR.
- Newton or secant refinement. Find the zero of near the grid peak, which converges faster than golden-section search when the start is close.
- Iterated or recursive search. Repeat a smaller FFT on a narrower band, or use a dichotomous search between two bins.
- Data removal for M-PSK. Apply the estimator to , then divide by , which cuts the range to and adds squaring loss.
- Several tones. For more than one tone, subspace methods such as MUSIC and ESPRIT resolve tones that are closer than .
When to use it
Use it when the SNR per sample is low, the block is long, and the full range is needed: initial acquisition of a carrier offset from a preamble, Doppler estimation, or measurement of a tone frequency. At moderate SNR, if cost matters, use the Kay or Luise and Reggiannini estimator.
Pitfalls
- No zero padding. With , the best grid point can be in a side lobe or on the wrong side of the peak at bin edges. Pad to at least before the local search.
- Searching from the grid peak only. Without the fine search, the error is the grid error, up to half a grid step, which at high SNR is far above the bound: 12 times at 10 dB in the measurement.
- Wrong bracket. A bracket wider than the main lobe can hold two local maxima, and the golden-section search may end on the wrong one.
- Data left in the signal. Modulated symbols spread the tone over the band. Remove them first.
- Expecting Gaussian errors below threshold. Below threshold, the mean square error is dominated by a few outliers. Report the outlier rate as well as the MSE.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/rife-boorstyn-frequency-estimator/. The authors are listed in prov/749SAD.jsonl.
"""Rife and Boorstyn maximum likelihood frequency estimation of one complex tone.
For r[t] = A e^(j(omega t + phi)) + w[t], t = 0, ..., N-1, with unknown A, phi
and omega, and white circular Gaussian noise, the maximum likelihood estimate
of omega is the frequency that maximizes the periodogram
P(omega) = |sum_t r[t] e^(-j omega t)|^2 / N.
The search is done in two steps: a coarse search on a zero-padded FFT grid of
K >= 4N points, then a golden-section search on the two grid cells around the
largest grid value. The result is in radians per sample, in [-pi, pi).
"""
import cmath
import math
from typing import Sequence
def fft(x: Sequence[complex]) -> list[complex]:
"""Radix-2 decimation-in-time FFT, X[k] = sum_t x[t] e^(-2 pi j k t / K); len(x) a power of 2."""
n = len(x)
if n & (n - 1):
raise ValueError("length must be a power of two")
a = list(x)
j = 0
for i in range(1, n): # bit-reversal permutation
bit = n >> 1
while j & bit:
j ^= bit
bit >>= 1
j |= bit
if i < j:
a[i], a[j] = a[j], a[i]
size = 2
while size <= n:
w = cmath.exp(-2j * math.pi / size)
for s in range(0, n, size):
wk = 1 + 0j
for k in range(size // 2):
u, v = a[s + k], a[s + k + size // 2] * wk
a[s + k], a[s + k + size // 2] = u + v, u - v
wk *= w
size *= 2
return a
def periodogram(r: Sequence[complex], omega: float) -> float:
"""P(omega) = |sum_t r[t] e^(-j omega t)|^2 / N."""
s = sum(x * cmath.exp(-1j * omega * t) for t, x in enumerate(r))
return abs(s) ** 2 / len(r)
def golden_max(f, a: float, b: float, tol: float) -> float:
"""The maximizer of a unimodal f on [a, b], to within tol, by golden-section search."""
g = (math.sqrt(5.0) - 1.0) / 2.0
c, d = b - g * (b - a), a + g * (b - a)
fc, fd = f(c), f(d)
while b - a > tol:
if fc >= fd:
b, d, fd = d, c, fc
c = b - g * (b - a)
fc = f(c)
else:
a, c, fc = c, d, fd
d = a + g * (b - a)
fd = f(d)
return (a + b) / 2.0
def rb_estimate(r: Sequence[complex], oversample: int = 4, tol: float = 1e-10) -> float:
"""The ML frequency estimate in radians per sample, in [-pi, pi)."""
n = len(r)
k = 1
while k < oversample * n:
k *= 2
x = fft(list(r) + [0j] * (k - n)) # @line L1
best = max(range(k), key=lambda i: abs(x[i])) # @line L2
a, b = 2.0 * math.pi * (best - 1) / k, 2.0 * math.pi * (best + 1) / k # @line L3
omega = golden_max(lambda w: periodogram(r, w), a, b, tol) # @line L4
return (omega + math.pi) % (2.0 * math.pi) - math.pi # @line L5
def crb(n: int, snr: float) -> float:
"""The Cramer-Rao bound 6 / (SNR N (N^2 - 1)) on the variance of omega_hat."""
return 6.0 / (snr * n * (n * n - 1))
test_rife_boorstyn_frequency_estimator.py 67 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/rife-boorstyn-frequency-estimator/. The authors are listed in prov/749SAD.jsonl.
import cmath
import math
import random
from rife_boorstyn_frequency_estimator import crb, fft, periodogram, rb_estimate
def tone(rng, n, omega, snr=None, phi=0.0):
sd = math.sqrt(0.5 / snr) if snr else 0.0
return [cmath.exp(1j * (omega * t + phi)) + (complex(rng.gauss(0, sd), rng.gauss(0, sd)) if sd else 0j) for t in range(n)]
def wrap(x):
return (x + math.pi) % (2 * math.pi) - math.pi
def test_fft_matches_the_direct_dft() -> None:
rng = random.Random(1)
for k in (1, 2, 8, 64, 128):
x = [complex(rng.gauss(0, 1), rng.gauss(0, 1)) for _ in range(k)]
X = fft(x)
for i in range(k):
d = sum(x[t] * cmath.exp(-2j * math.pi * i * t / k) for t in range(k))
assert abs(X[i] - d) < 1e-9
def test_exact_without_noise() -> None:
rng = random.Random(2)
for _ in range(60):
n = rng.randrange(4, 50)
om = rng.uniform(-math.pi, math.pi)
e = wrap(rb_estimate(tone(rng, n, om, phi=rng.uniform(-3, 3))) - om)
assert abs(e) < 1e-7
def test_matches_a_dense_grid_search() -> None:
# Brute force: the maximizer of P over a dense grid of 4000 points. The RB
# estimate is at least as good and lies within one grid step of it.
rng = random.Random(3)
n, m = 16, 4000
grid = [-math.pi + 2 * math.pi * i / m for i in range(m)]
for _ in range(6):
r = tone(rng, n, rng.uniform(-3, 3), snr=10 ** 0.2, phi=rng.uniform(-3, 3))
est = rb_estimate(r)
g = max(grid, key=lambda w: periodogram(r, w))
assert periodogram(r, est) >= periodogram(r, g) - 1e-9
assert abs(wrap(est - g)) < 2 * math.pi / m
def test_mse_against_the_crb() -> None:
n, trials = 32, 150
ratio = {}
for snr_db in (-6, 0, 10):
snr = 10 ** (snr_db / 10)
rng = random.Random(2)
se = 0.0
for _ in range(trials):
om = rng.uniform(-3, 3)
e = wrap(rb_estimate(tone(rng, n, om, snr, rng.uniform(-3, 3))) - om)
se += e * e
ratio[snr_db] = se / trials / crb(n, snr)
assert 0.75 < ratio[0] < 1.5
assert 0.75 < ratio[10] < 1.35
assert ratio[-6] > 20 # below the threshold: outliers at a wrong peak
History
David Rife and Robert Boorstyn, at Bell Laboratories and New York University, published the estimator in the IEEE Transactions on Information Theory in 1974. They derived the Cramer-Rao bounds for the amplitude, the phase and the frequency of one complex tone in discrete-time white noise, showed that the ML frequency is the periodogram peak, proposed to compute it with a coarse FFT search and a fine search, and analyzed the threshold where outliers start. In 1976 they extended the work to several tones. Their bound and their estimator became the reference for all later fast frequency estimators, such as those of Kay in 1989 and of Luise and Reggiannini in 1995.
References
- D. C. Rife and R. R. Boorstyn, Single-tone parameter estimation from discrete-time observations, IEEE Transactions on Information Theory 20(5), 1974, pages 591 to 598, the Cramer-Rao bounds for amplitude, phase and frequency, the maximum likelihood estimator as the periodogram peak, the coarse FFT and fine search, and the threshold analysis
- Umberto Mengali and Aldo N. D'Andrea, Synchronization Techniques for Digital Receivers, Plenum Press, 1997, Chapter 3 (carrier frequency recovery with linear modulations, the maximum likelihood data-aided estimator)
- Steven M. Kay, Fundamentals of Statistical Signal Processing, Volume I: Estimation Theory, Prentice Hall, 1993, Chapter 7 (maximum likelihood estimation)
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 749SAD Edit this page History Report an error Markdown