Algorithmcore
Viterbi and Viterbi phase estimation
Also called Viterbi-Viterbi algorithm, Mth-power phase estimator.
Estimates the carrier phase of M-PSK in feedforward form by raising samples to the Mth power and averaging over a block.
- Solves
- Carrier recovery
- Time
- O(N) worst
- Space
- O(1) extra
- Where
- N = the number of symbols in the block
- Model
- Real RAM
- Properties
- deterministicfeedforwardnon data aided
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Andrew J. Viterbi, Audrey M. Viterbi, 1983
Viterbi and Viterbi (VV) phase estimation finds the carrier phase of an M-PSK signal from one block of samples, with no feedback and no knowledge of the data. It writes each sample as , removes the data by multiplying the angle by , weights each sample by a power of its modulus, sums, and divides the angle of the sum by . It is the block, or feedforward, member of the carrier recovery family. The Costas loop and the squaring loop remove the data in the same way but in a feedback loop that runs symbol by symbol, and decision-directed carrier recovery uses decisions instead of a power. The estimate has an -fold ambiguity, and at high SNR its variance approaches the modified Cramer-Rao bound . Because it needs no acquisition time, it suits burst transmission, and at low SNR the unwrapping of successive block estimates can fail, which is the block form of a cycle slip.
In plain words
In QPSK each symbol turns the carrier by one of four angles. If you multiply every angle by four, the four data angles all fall on the same angle, and only four times the carrier phase is left. So the receiver takes each sample, multiplies its angle by four, adds all of them up as arrows, and reads the angle of the total. Dividing by four gives the carrier phase, but only up to a quarter turn, because a quarter turn of the carrier also looks the same after the multiplication. Long arrows count more than short ones, but not too much, because the strong samples are not always the reliable ones.
The problem
The input is a block , , one sample per symbol after matched filtering and correct timing. The data are unknown and uniform on M-PSK with a known offset (for example for QPSK with points on the diagonals), and is white, . The phase is constant over the block. Output an estimate of modulo , in .
The algorithm
VV(r[0..N-1], M, p, phase0)- 1
S <- 0 - 2
for k <- 0 to N - 1 do - 3
rho <- |r[k]|; psi <- arg r[k] - 4
S <- S + rho^p * exp(j * M * psi) ▷ the data angle is removed - 5
theta <- (arg S - M * phase0) / M - 6
return theta reduced to [-pi/M, pi/M)
Line L4 is the nonlinearity with . With it is , the plain Mth power, and the estimator is up to the offset; with only the angles are used. Line L5 removes the angle that the offset adds; for QPSK on the diagonals , and the estimate is . For a long signal, the receiver runs VV on successive blocks, or on a sliding window, and unwraps: it moves each new estimate by a multiple of to the value nearest to the previous one.
Example
QPSK on the diagonals, rad, dB, , (random data and noise, seed 6):
| 0 | ||||
| 1 | ||||
| 2 | ||||
| 3 |
The sum is , with . Line L5 gives , and line L6 adds to reach in . The error is rad. The four sample angles differ by about multiples plus noise, but after multiplication by 4 the terms point in roughly the same direction.
With and 600 random blocks per point (seed 4), the mean square error over the MCRB was (measurements):
| 0 dB | ||||
| 5 dB | ||||
| 10 dB |
At 10 dB the error is close to the bound. At lower SNR the nonlinearity enhances the noise, and the powers and do better than the plain fourth power.
Correctness
Claim. maximizes , and its maximizers are . Without noise modulo . In circular Gaussian noise, the error modulo is symmetric about zero, so the estimator is unbiased. At high SNR its variance is , the MCRB.
Key steps. , so the data drops out of . Then , which is largest where line L5 puts . Complex conjugation maps M-PSK and circular noise onto themselves, which gives the symmetry. A first-order expansion of the angle in the noise gives with . The first three claims are theorems; the high-SNR variance is a closed form under assumptions, and the table above is a measurement.
Proof: The VV estimate maximizes sum rho^p cos(M(psi - phi - phase0)), is exact modulo 2 pi/M without noise, is unbiased modulo 2 pi/M in circular noise, and reaches the MCRB at high SNRfull
The input is , , where with independent and uniform on , the offset is known, and is white, . Lines L2 to L4 form , where . Line L5 sets , and line L6 reduces it to . Write for equality modulo .
Lemma 1 (the data is removed). For every data symbol, .
Proof. .
Theorem 1 (what the estimate maximizes). For every , let . Then is a maximizer of , and the set of maximizers is when .
Proof. . This is at most , with equality exactly when , that is . Line L6 picks the representative in .
For , , which is the first nonconstant term of the low-SNR expansion of the non-data-aided log-likelihood of M-PSK. Other trade that low-SNR form against a smaller noise enhancement at moderate SNR.
Theorem 2 (exact without noise). If for all and , then , for every .
Proof. and , so by Lemma 1 for every and . Line L5 gives .
So the estimate can only find modulo ; this is the phase ambiguity of M-PSK, and an unwrapping step or differential encoding resolves it.
Theorem 3 (unbiased modulo ). Let be the representative of in . Then has a distribution symmetric about , so .
Proof. Let , an th root of unity, and , again and independent of the data. Then , and , so . Complex conjugation maps the set of th roots of unity onto itself and preserves the uniform law, and it preserves the law of circular Gaussian noise. So has the same joint law as , and has the same law as . Hence and have the same law on , up to the null event , and so do and .
Theorem 4 (high-SNR variance). As , , the modified Cramer-Rao bound, for every fixed .
Proof. Write , and with independent . To first order in the noise, and . With , in mean square, so and . Its variance is . Outliers, where the noise moves by more than , need a noise sample of size of order ; for fixed their probability is bounded by a Gaussian tail , which is , and is bounded, so they do not change the leading term.
This is a closed form under assumptions (high SNR). At moderate SNR the noise terms of higher order, enhanced by the power , raise the variance above the bound; the tests measure this, for QPSK with , at 5 and 10 dB.
Complexity. Lines L2 to L4 run times with work each; lines L1, L5 and L6 are . The total is time and extra space.
Complexity
Each sample costs one modulus, one angle, one power and one complex exponential, so the block costs time in the real RAM, with extra space. For , needs only complex squarings and no trigonometric function. A sliding window of length updates in per sample by adding the new term and subtracting the old one.
Properties
- Feedforward. There is no loop, so there is no acquisition time and no hang-up. Every block gives an estimate of the same quality.
- Non-data-aided. The data need not be known or decided. The estimator works at SNRs where decisions are poor.
- Ambiguity . The estimate is modulo : for BPSK, for QPSK. A known word or differential encoding must resolve it.
- Self noise and noise enhancement. At low SNR, the power multiplies the noise: terms of the type noise times noise appear in . The variance is then several times the MCRB, as the table shows.
- Choice of . Viterbi and Viterbi studied the nonlinearity ; low powers ( or ) are a good choice for QPSK at moderate SNR, and is the low-SNR maximum likelihood form.
- Only for constant phase. The block length is a tradeoff: longer blocks lower the noise, but the phase must stay constant over the block, and a residual frequency offset adds a phase change over it.
Variants and improvements
- Sliding window with unwrapping. A running sum of the last terms gives an estimate per symbol, and unwrapping follows a phase that moves beyond .
- Plain Mth power. : , the low-SNR approximation of the non-data-aided ML estimator for M-PSK.
- QAM. For square QAM, the fourth power still keeps a nonzero mean, , so works, with much more self noise. Selecting only the corner points or the points of a given ring reduces it.
- Decision-directed refinement. Use the VV estimate to start a decision-directed loop, or recompute the block estimate with decisions.
- Joint frequency and phase. With a residual frequency offset, apply a frequency estimator to first, for example the Kay estimator, then VV on the derotated block.
When to use it
Use VV for M-PSK in burst mode, in satellite modems, or after a coarse frequency correction in coherent optical receivers, where a block estimate is wanted at once and the SNR is moderate. For QPSK at a few dB SNR, choose or . For QAM, or at high SNR with a continuous signal, a decision-directed loop is simpler and has no self noise.
Pitfalls
- Forgetting the offset. For QPSK on the diagonals, is off by before the division. Omitting shifts every estimate by .
- Not unwrapping. Block estimates are in . A phase that drifts past jumps by unless the blocks are unwrapped.
- Wrong unwrapping at low SNR. If two consecutive estimates differ by more than because of noise, the unwrapping adds a wrong multiple of , and all later symbols are rotated. This is a cycle slip of the block estimator.
- Too long a block with a frequency offset. The term turns inside the sum. If is not small, the sum cancels and the estimate is meaningless.
- Using at low SNR. The plain Mth power enhances the noise most. At 5 dB for QPSK it had about 50 percent more error than in the table.
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/viterbi-viterbi-phase-estimation/. The authors are listed in prov/VA0M3B.jsonl.
"""Viterbi and Viterbi (VV) feedforward carrier phase estimation for M-PSK.
Write each sample in polar form, r[k] = rho e^(j psi). Multiplying the angle
by M removes the M-PSK data, because M times a data angle 2 pi i / M + phase0
is M phase0 modulo 2 pi. The modulus is replaced by a nonlinearity F(rho) =
rho^p. The estimate is
theta_hat = (arg(sum_k rho_k^p e^(j M psi_k)) - M phase0) / M,
wrapped to [-pi/M, pi/M). It has the M-fold ambiguity of the constellation:
it estimates theta modulo 2 pi / M. With p = M it is the plain Mth power
estimator arg(sum r^M) / M.
"""
import cmath
import math
from typing import Sequence
def wrap(x: float, period: float) -> float:
"""x reduced to [-period/2, period/2)."""
return (x + period / 2.0) % period - period / 2.0
def vv_estimate(r: Sequence[complex], m: int, p: float = 2.0, phase0: float = 0.0) -> float:
"""The VV phase estimate for M-PSK with first point at angle phase0, F(rho) = rho^p."""
s = 0j # @line L1
for x in r: # @line L2
rho, psi = abs(x), cmath.phase(x) # @line L3
s += rho**p * cmath.exp(1j * m * psi) # @line L4
theta = (cmath.phase(s) - m * phase0) / m # @line L5
return wrap(theta, 2.0 * math.pi / m) # @line L6
def objective(r: Sequence[complex], m: int, phi: float, p: float = 2.0, phase0: float = 0.0) -> float:
"""sum_k rho_k^p cos(M (psi_k - phi - phase0)), the function that the VV estimate maximizes."""
return sum(abs(x) ** p * math.cos(m * (cmath.phase(x) - phi - phase0)) for x in r)
def unwrap(estimates: Sequence[float], m: int) -> list[float]:
"""Unwrap block estimates: move each by a multiple of 2 pi / M to the one nearest the previous."""
period = 2.0 * math.pi / m
out: list[float] = []
for t in estimates:
if out:
t = out[-1] + wrap(t - out[-1], period)
out.append(t)
return out
test_viterbi_viterbi_phase_estimation.py 89 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/viterbi-viterbi-phase-estimation/. The authors are listed in prov/VA0M3B.jsonl.
import cmath
import math
import random
from viterbi_viterbi_phase_estimation import objective, unwrap, vv_estimate, wrap
Q0 = math.pi / 4 # QPSK points at pi/4 + i pi/2
def psk_block(rng, m, n, theta, snr=None, phase0=0.0):
sd = math.sqrt(0.5 / snr) if snr else 0.0
out = []
for _ in range(n):
a = cmath.exp(1j * (2 * math.pi * rng.randrange(m) / m + phase0))
w = complex(rng.gauss(0, sd), rng.gauss(0, sd)) if sd else 0j
out.append(a * cmath.exp(1j * theta) + w)
return out
def test_exact_without_noise() -> None:
rng = random.Random(1)
for m, phase0 in ((2, 0.0), (4, Q0), (4, 0.0), (8, 0.0)):
for _ in range(50):
th = rng.uniform(-math.pi / m, math.pi / m) * 0.999
r = psk_block(rng, m, 16, th, phase0=phase0)
for p in (0, 1, 2, m):
assert abs(vv_estimate(r, m, p, phase0) - th) < 1e-9
def test_ambiguity_modulo_two_pi_over_m() -> None:
rng = random.Random(2)
r = psk_block(rng, 4, 16, 1.0, phase0=Q0)
assert abs(vv_estimate(r, 4, 2, Q0) - (1.0 - math.pi / 2)) < 1e-9
r = psk_block(rng, 2, 16, 2.0)
assert abs(vv_estimate(r, 2, 2) - (2.0 - math.pi)) < 1e-9
def test_maximizes_the_objective_against_a_grid() -> None:
# Brute force: the best of 4000 grid points in one period cannot beat the closed form.
rng = random.Random(3)
for m, phase0, p in ((4, Q0, 2), (4, Q0, 0), (8, 0.0, 1), (2, 0.0, 2)):
r = psk_block(rng, m, 24, 0.1, snr=10 ** 0.3, phase0=phase0)
t = vv_estimate(r, m, p, phase0)
period = 2 * math.pi / m
grid = [-period / 2 + period * i / 4000 for i in range(4000)]
g = max(grid, key=lambda x: objective(r, m, x, p, phase0))
best = objective(r, m, t, p, phase0)
assert best >= objective(r, m, g, p, phase0) - 1e-12
assert abs(wrap(g - t, period)) <= period / 4000
def test_mse_against_the_mcrb() -> None:
# QPSK, N = 32, MCRB = 1/(2 N SNR). At 10 dB all nonlinearities are close to it;
# at 5 dB, p = 1 or 2 is clearly better than the plain fourth power p = 4.
n, trials = 32, 600
ratio = {}
for snr_db in (5, 10):
snr = 10 ** (snr_db / 10)
mcrb = 1 / (2 * n * snr)
for p in (1, 2, 4):
rng = random.Random(4)
se = 0.0
for _ in range(trials):
th = rng.uniform(-0.3, 0.3)
e = wrap(vv_estimate(psk_block(rng, 4, n, th, snr, Q0), 4, p, Q0) - th, math.pi / 2)
se += e * e
ratio[snr_db, p] = se / trials / mcrb
for p in (1, 2, 4):
assert 0.9 < ratio[10, p] < 1.8
assert ratio[10, 2] < 1.35
assert ratio[5, 2] < 0.8 * ratio[5, 4]
assert ratio[5, 1] < 0.8 * ratio[5, 4]
assert ratio[5, 2] > 1.5
def test_unwrap_tracks_a_drifting_phase() -> None:
# Blocks of 32 QPSK symbols with a phase ramp over 3 rad, beyond the range pi/4.
rng = random.Random(5)
ests, truth = [], []
for b in range(60):
th = 0.05 * b
truth.append(th)
ests.append(vv_estimate(psk_block(rng, 4, 32, th, 10.0, Q0), 4, 2, Q0))
assert max(ests) < math.pi / 4
u = unwrap(ests, 4)
assert max(abs(a - b) for a, b in zip(u, truth)) < 0.2
History
Andrew J. Viterbi and Audrey M. Viterbi published the estimator in the IEEE Transactions on Information Theory in 1983. They designed it for burst digital transmission, such as time-division multiple access satellite links, where a carrier loop has no time to acquire at the start of each burst. Their paper considered a general nonlinearity of the modulus and computed the variance for several choices. The Mth power idea itself is older: the squaring and Mth power loops of the 1960s and 1970s used it in feedback form. The VV estimator later became the standard feedforward phase recovery for QPSK in digital coherent optical receivers.
References
- A. J. Viterbi and A. M. Viterbi, Nonlinear estimation of PSK-modulated carrier phase with application to burst digital transmission, IEEE Transactions on Information Theory 29(4), 1983, pages 543 to 551, the feedforward estimator with the nonlinearity F(rho) e^(j M psi) of each sample, and its variance against the nonlinearity
- Umberto Mengali and Aldo N. D'Andrea, Synchronization Techniques for Digital Receivers, Plenum Press, 1997, Chapter 5 (carrier phase recovery with linear modulations, the non-data-aided feedforward estimator for M-PSK)
- Heinrich Meyr, Marc Moeneclaey and Stefan A. Fechtel, Digital Communication Receivers, Wiley, 1998, Chapter 5 (feedforward carrier phase estimation for M-PSK, the Viterbi and Viterbi algorithm)
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 VA0M3B Edit this page History Report an error Markdown