Algorithmadvanced
Zheng and Xiao fading simulator
Also called improved sum-of-sinusoids simulator.
A sum of M sinusoids with random arrival angles and phases. Its autocorrelation is exactly Omega J0(2 pi f_D tau) for any M; a phase per sinusoid also fixes the higher-order statistics.
- Time
- O(M T) worst
- Space
- O(M) extra
- Where
- M = the number of sinusoids; T = the number of output samples
- Model
- Real RAM
- Properties
- exact second order statisticsgaussian only as m growsrandomizedwide sense stationary
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Yahong Rosa Zheng, Chengshan Xiao, 2002
The Zheng-Xiao simulator is a random generator of a fading gain for Clarke's model: it adds sinusoids whose arrival angles, gains and phases are drawn at random, once per channel. Clarke's model is the target, the autocorrelation ; the Jakes simulator approximates it with fixed angles and is deterministic, while this simulator matches the second-order statistics of Clarke's model exactly, for any , as an average over its random parameters. The filtered Gaussian noise simulator is the other common generator, a Gaussian process by construction. The 2003 form shares one phase among all sinusoids; Xiao, Zheng and Beaulieu (2006) showed that this form is not Gaussian over short times and use a phase per sinusoid, which is the form given here.
In plain words
Picture the receiver of Clarke's model, with waves arriving from all directions. The Jakes simulator puts a fixed ring of waves around the receiver. This simulator spins the ring by a random angle, gives each wave a random strength split between the real and imaginary parts, and starts each wave at a random point of its cycle. One draw of these random numbers gives one fading channel. A new draw gives a new, independent channel. Because the spin covers every angle, the average correlation over many channels is exactly the one Clarke's model asks for, even with only a few waves. With few waves, one channel still looks less random than real fading.
The problem
The input is the maximum Doppler shift , the mean power , the number of sinusoids , a source of random numbers, and times . The output is one random realization at the given times. The goal is a process whose ensemble statistics match Clarke's model: , , quadratures with equal autocorrelation and zero cross-correlation, and a distribution close to circular complex Gaussian, so that the envelope is Rayleigh. The model is flat time-correlated fading; the simulator gives the channel only, and the receiver's CSIR or CSIT is set by the simulation that uses it.
The algorithm
ZHENG-XIAO(M, f_D, Ω, t, rng)- 1
θ ← uniform on [-π, π) - 2
ψₙ ← uniform on [-π, π) for n = 1 .. M ▷ independent - 3
φₙ ← uniform on [-π, π) for n = 1 .. M ▷ one phase per sinusoid (2006) - 4
αₙ ← (2πn - π + θ) / (4M) for n = 1 .. M - 5
X_c ← Σₙ cos ψₙ cos(2π f_D t cos αₙ + φₙ); X_s ← Σₙ sin ψₙ cos(2π f_D t cos αₙ + φₙ) - 6
return √(2Ω/M) (X_c + j X_s)
Lines L1 to L4 are drawn once per channel and then kept for all times . Line L4 places the angles at equal steps inside , shifted together by the random . Only a quarter circle is needed, because waves at , , and give the same Doppler frequency up to sign. Line L2 gives each sinusoid a random gain angle, which splits it between the two quadratures. Line L3 gives it a random Doppler phase. In eq. (14) of Zheng and Xiao (2003), line L3 is a single phase shared by all ; the per-sinusoid phases are the 2006 correction. Line L6 scales the sum so that .
Example
Take and . Line L4 gives eight angles spaced by degrees; for they are 5.6, 16.9, 28.1, 39.4, 50.6, 61.9, 73.1 and 84.4 degrees, and the Doppler frequencies are , from 0.995 down to 0.098.
The ensemble autocorrelation, averaged over alone with the other parameters averaged out, is with . A numerical integral over matches within at , 0.38274, 1, 3 and 10, for , 2 and 8. Compare the Jakes simulator with , whose time-average autocorrelation at is -0.049 instead of .
The fourth moment shows the 2006 correction. A Rayleigh gain has .
| version | , formula | mean of 12000 draws | |
|---|---|---|---|
| a phase per sinusoid (2006) | 1.9375 | 1.939 | |
| one common phase (2003) | 2.8125 | 2.808 |
With one common phase, at every sinusoid has the same phase, so , a Gaussian-like sum times a common random factor. Its distribution is far from Rayleigh for any ; as grows the Doppler terms spread the phases apart, so the statistics depend on .
Correctness
Claim. For any , with independent uniform and , and phases that are independent of and (either one per sinusoid or shared): ; the quadratures each have the autocorrelation ; and their cross-correlation is 0. With a phase per sinusoid, the terms are independent given , so tends to a circular complex Gaussian as grows, by the central limit theorem, and .
Key step. The random cancel all cross terms between different sinusoids and leave . As runs over , runs over an interval of length , and the intervals tile . So the average is . The second-order part is Theorem 1 of Zheng and Xiao (2003). The proof file gives the full argument and derives both fourth moments.
Proof: The Zheng-Xiao simulator has the autocorrelation of Clarke's model for every M, and its fourth moment depends on how the phases are drawnfull
Write , , and , where , and the phases are independent and uniform on . In the per-sinusoid form the are independent; in the common form for all . The output is
so that and .
Lemma 1 (phase averages). For a uniform , , and . For a uniform and constants , , and .
Proof. Each is the average of a trigonometric polynomial over a full period: write and , and drop the terms with a nonzero multiple of the variable.
Lemma 2 (the angle average). For every real , .
Proof. As runs uniformly over , runs uniformly over with density . The intervals are disjoint and their union is . So the left side is . Bessel's integral is , and the substitution shows that the halves and give equal parts.
Theorem 1 (second order). In both forms, for all and ,
so , and each quadrature of has autocorrelation .
Proof. , because the are independent of and of the phases. For , . For , Lemma 1 gives for the first factor, and, conditional on , for the second one, in both forms, because only enters it. So the sum is by Lemma 2. The same steps with give , and with give the cross-correlation . Then , and the factor gives .
The result does not depend on , so both forms are wide-sense stationary, and it holds for every .
Theorem 2 (fourth moment, a phase per sinusoid). for every , and tends in distribution to a circular complex Gaussian with variance as .
Proof. Condition on . The terms are then independent, with , (by ) and , (by Lemma 1, since is uniform modulo ). Expand . A term is nonzero only if no index appears once; the pairings and each give , the pairing gives , and gives . So , which does not depend on . Multiply by . For the limit, given the real and imaginary parts are sums of independent bounded terms with total covariance , so the Lyapunov form of the central limit theorem applies to , and the limit does not depend on .
A circular complex Gaussian with has , so the excess measures the distance from Rayleigh fading.
Theorem 3 (fourth moment, the common phase at ). .
Proof. At , for all , so with , and is independent of . By the same pairing count with , . With , , and the factor gives the claim.
So the common form has , not , as : is a Gaussian-like variable times the independent factor , and is not Gaussian for any . For the Doppler terms differ between sinusoids and spread the phases, so the fourth moment changes with . This is the defect that Xiao, Zheng and Beaulieu (2006) remove by using one phase per sinusoid. For , Theorems 2 and 3 give 1.9375 and 2.8125.
Complexity
Lines L1 to L4 draw random numbers and compute cosines, per channel. Each output sample costs cosines and multiplications, so samples cost in the real RAM, with extra space. A Monte Carlo study with many channels draws new parameters for each one.
Properties
- Exact second order. The autocorrelations and the cross-correlation of Clarke's model hold exactly, for every , over the ensemble. This is a theorem, not an approximation in .
- Wide-sense stationary. The ensemble autocorrelation does not depend on .
- Not ergodic for small . One realization has the time-average autocorrelation , a quadrature with points, which differs from at large lags. Statistics must be averaged over many draws, not over a long run of one draw.
- Gaussian only in the limit. For finite the gain is a sum of bounded terms, so it is not exactly Gaussian, and is bounded by . The fourth moment is instead of 2.
- Higher-order statistics. With one phase per sinusoid, the envelope distribution, the level crossing rate and the average fade duration approach those of Clarke's model as grows; to 16 is common.
Variants and improvements
- The 2003 form with a common phase. It has the same second-order statistics, but it is not Gaussian over short times and the autocorrelation of its squared envelope depends on . The finding is credited to Sun, Ye and Choi and to Patel, Stuber and Pratt (2005); Xiao, Zheng and Beaulieu (2006) gave the correction.
- The 2006 models. Xiao, Zheng and Beaulieu (2006) also give a model with a random offset per sinusoid, , and a Rician model with a line-of-sight term; see Rician fading.
- Several uncorrelated channels. Separate parameters for each channel make the channels independent, which Zheng and Xiao (2003) use for multiple uncorrelated waveforms. Deterministic models need special angle sets for this.
- Deterministic sum of sinusoids. The Jakes simulator uses fixed angles. It is cheaper to set up, but its statistics are only approximate.
When to use it
Use it for Monte Carlo simulation of time-correlated Rayleigh fading when the channel must be evaluated at arbitrary times, for example with a Doppler that changes, or for channels in continuous time. Draw new parameters for each simulated channel and use the per-sinusoid phases. Use the filtered Gaussian noise simulator when an exactly Gaussian process on a fixed grid is needed, and an independent draw per block when the fading is block fading.
Pitfalls
- One long run instead of many draws. The exact statistics are ensemble averages. One draw with small has the wrong time averages.
- The common phase of 2003. Copying eq. (14) as printed gives a process whose squared envelope is not stationary. Use one phase per sinusoid.
- Too few sinusoids for tail statistics. The envelope is bounded and its tails are lighter than Rayleigh. Deep fades, outage and error rates at high need large enough, or a Gaussian generator.
- Normalization. Each quadrature sum has variance . Papers and codes use different scale factors; the factor here gives . Check the scale before comparing across simulators.
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/zheng-xiao-fading-simulator/. The authors are listed in prov/97VH88.jsonl.
"""The Zheng-Xiao statistical sum-of-sinusoids simulator for Rayleigh fading.
Eq. (14) of Zheng and Xiao 2003: with M sinusoids,
X_c(t) = sum_n cos(psi_n) cos(w_d t cos(alpha_n) + phi_n),
X_s(t) = sum_n sin(psi_n) cos(w_d t cos(alpha_n) + phi_n),
alpha_n = (2 pi n - pi + theta) / (4 M), n = 1..M,
where psi_n, phi_n and theta are independent and uniform on [-pi, pi).
The fading gain is h = sqrt(2 Omega / M) (X_c + j X_s), so E|h|^2 = Omega.
The 2003 paper used one phase phi for all n. Xiao, Zheng and Beaulieu 2006
showed that this form is not Gaussian for short times and that its squared
envelope is not stationary; they use an independent phi_n for each n. The
default here is the corrected form; common_phase=True gives the 2003 form.
Both have the exact second-order statistics of Clarke's model.
"""
import math
import random
def draw_parameters(m: int, rng: random.Random, common_phase: bool = False) -> tuple[list[float], list[float], list[float]]:
"""One random draw of the angles alpha_n, the gain phases psi_n and the Doppler phases phi_n."""
if m < 1:
raise ValueError("need M >= 1")
theta = rng.uniform(-math.pi, math.pi) # @line L1
psi = [rng.uniform(-math.pi, math.pi) for _ in range(m)] # @line L2
if common_phase:
phi = [rng.uniform(-math.pi, math.pi)] * m
else:
phi = [rng.uniform(-math.pi, math.pi) for _ in range(m)] # @line L3
alpha = [(2.0 * math.pi * n - math.pi + theta) / (4.0 * m) for n in range(1, m + 1)] # @line L4
return alpha, psi, phi
def gains(fd: float, times: list[float], alpha: list[float], psi: list[float], phi: list[float], omega: float = 1.0) -> list[complex]:
"""h(t) at the given times for one fixed draw of the parameters."""
m = len(alpha)
wd = 2.0 * math.pi * fd
g = math.sqrt(2.0 * omega / m)
cp = [math.cos(p) for p in psi]
sp = [math.sin(p) for p in psi]
nu = [math.cos(a) for a in alpha]
out = []
for t in times:
osc = [math.cos(wd * t * nu[n] + phi[n]) for n in range(m)]
xc = sum(cp[n] * osc[n] for n in range(m)) # @line L5
xs = sum(sp[n] * osc[n] for n in range(m))
out.append(g * complex(xc, xs)) # @line L6
return out
def zheng_xiao(m: int, fd: float, times: list[float], rng: random.Random, omega: float = 1.0, common_phase: bool = False) -> list[complex]:
"""One realization of the Zheng-Xiao simulator with M sinusoids at the given times."""
alpha, psi, phi = draw_parameters(m, rng, common_phase)
return gains(fd, times, alpha, psi, phi, omega)
def theta_average(m: int, x: float, points: int = 2000) -> float:
"""E over theta of (1 / M) sum_n cos(x cos(alpha_n)), by Simpson's rule over theta in [-pi, pi].
This is the normalized autocorrelation E[h(t + tau) conj(h(t))] / Omega at
x = 2 pi f_D tau. The theorem of Zheng and Xiao says that it equals J0(x).
"""
if points % 2:
points += 1
h = 2.0 * math.pi / points
def f(theta):
return sum(math.cos(x * math.cos((2.0 * math.pi * n - math.pi + theta) / (4.0 * m))) for n in range(1, m + 1)) / m
s = f(-math.pi) + f(math.pi)
for k in range(1, points):
s += (4 if k % 2 else 2) * f(-math.pi + k * h)
return s * h / 3.0 / (2.0 * math.pi)
def fourth_moment(m: int, common_phase: bool) -> float:
"""E|h(0)|^4 / Omega^2: 2 - 1 / (2M) with a phase per sinusoid, 3 - 3 / (2M) with one common phase."""
return 3.0 - 1.5 / m if common_phase else 2.0 - 0.5 / m
def j0(x: float, points: int = 2048) -> float:
"""J0(x) = (1 / 2 pi) integral over [0, 2 pi) of cos(x sin t) dt, by the trapezoid rule."""
h = 2.0 * math.pi / points
return sum(math.cos(x * math.sin(k * h)) for k in range(points)) / points
test_zheng_xiao_fading_simulator.py 90 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/zheng-xiao-fading-simulator/. The authors are listed in prov/97VH88.jsonl.
import math
import random
from zheng_xiao_fading_simulator import (
draw_parameters,
fourth_moment,
gains,
j0,
theta_average,
zheng_xiao,
)
M = 8
def j0_series(x):
"""J0 by its power series, a second method for small x."""
s, t, k = 0.0, 1.0, 0
while abs(t) > 1e-18 or k < 5:
s += t
k += 1
t *= -(x / 2.0) ** 2 / (k * k)
return s
def test_angles_cover_a_quarter_circle() -> None:
rng = random.Random(9701)
for _ in range(100):
alpha, psi, phi = draw_parameters(M, rng)
assert len(alpha) == len(psi) == len(phi) == M
assert all(0.0 <= a <= math.pi / 2 for a in alpha)
steps = [alpha[n + 1] - alpha[n] for n in range(M - 1)]
assert all(abs(s - 2 * math.pi / (4 * M)) < 1e-12 for s in steps)
def test_exact_autocorrelation_over_theta() -> None:
# the theorem: the average over theta is J0(x) for any M, even M = 1
for m in (1, 2, 8):
for ft in (0.1, 0.38274, 1.0, 3.0, 10.0):
x = 2 * math.pi * ft
assert abs(theta_average(m, x) - j0(x)) < 1e-9
for x in (0.5, 2.0, 5.0):
assert abs(j0(x) - j0_series(x)) < 1e-10
def test_ensemble_power_and_autocorrelation() -> None:
rng = random.Random(9702)
trials = 4000
fd = 1.0
lags = [0.1, 0.25, 0.5, 1.0, 5.0]
acc = [0j] * len(lags)
cross = 0.0
power = 0.0
for _ in range(trials):
h = zheng_xiao(M, fd, [3.0] + [3.0 + t for t in lags], rng)
power += abs(h[0]) ** 2
cross += h[1].real * h[0].imag
for k in range(len(lags)):
acc[k] += h[k + 1] * h[0].conjugate()
assert abs(power / trials - 1.0) < 0.07
assert abs(cross / trials) < 0.05 # the quadratures are uncorrelated at any lag
for k, t in enumerate(lags):
assert abs(acc[k] / trials - j0(2 * math.pi * fd * t)) < 0.07
def test_fourth_moment_shows_the_2006_correction() -> None:
# E|h|^4 = 2 for Rayleigh fading. The phase per sinusoid gives 2 - 1/(2M) = 1.9375,
# one common phase gives 3 - 3/(2M) = 2.8125 at t = 0.
assert fourth_moment(M, False) == 1.9375 and fourth_moment(M, True) == 2.8125
# 12000 draws: the standard error is about 0.04 per-path and 0.09 common, and the two means differ by 0.875.
trials = 12000
for common, tol, seed in ((False, 0.15, 9703), (True, 0.35, 9704)):
rng = random.Random(seed)
s = 0.0
for _ in range(trials):
alpha, psi, phi = draw_parameters(M, rng, common_phase=common)
h = gains(1.0, [0.0], alpha, psi, phi)[0]
s += abs(h) ** 4
assert abs(s / trials - fourth_moment(M, common)) < tol
def test_omega_scales_power() -> None:
rng = random.Random(9705)
alpha, psi, phi = draw_parameters(M, rng)
a = gains(2.0, [0.0, 0.1, 0.7], alpha, psi, phi, omega=1.0)
b = gains(2.0, [0.0, 0.1, 0.7], alpha, psi, phi, omega=4.0)
assert all(abs(q - 2 * p) < 1e-12 for p, q in zip(a, b))
History
Pop and Beaulieu (2001) showed that the Jakes simulator is not wide-sense stationary and that random phases alone do not fix its higher-order statistics. Xiao and Zheng (2002) proposed a sum of sinusoids with random angles, gains and phases at a conference, and in 2003 Zheng and Xiao proved that the second-order statistics of their model match Clarke's model exactly for any number of sinusoids. Later work found that the 2003 model, with one phase for all sinusoids, is not Gaussian over short times and has a squared envelope whose autocorrelation is not stationary; Xiao, Zheng and Beaulieu (2006) corrected it with independent phases and gave new models for Rayleigh and Rician fading.
References
- Y. R. Zheng and C. Xiao, Simulation models with correct statistical properties for Rayleigh fading channels, IEEE Transactions on Communications 51(6), 2003, pages 920 to 928, Section III, eqs. (14) and (15) (the model) and Theorem 1 (its autocorrelation and cross-correlation functions)
- C. Xiao, Y. R. Zheng and N. C. Beaulieu, Novel sum-of-sinusoids simulation models for Rayleigh and Rician fading channels, IEEE Transactions on Wireless Communications 5(12), 2006, pages 3667 to 3679, Section II (the remark that corrects eq. (14) of the 2003 paper with one phase per sinusoid, and Theorem 3) and Section III (the Rician model)
- M. F. Pop and N. C. Beaulieu, Limitations of sum-of-sinusoids fading channel simulators, IEEE Transactions on Communications 49(4), 2001, pages 699 to 708, the statistics of the Jakes simulator that the random model corrects
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 97VH88 Edit this page History Report an error Markdown