Algorithmcore
Jakes fading simulator
Also called Jakes model, sum-of-sinusoids fading simulator.
Generates a fading waveform for Clarke's model as a fixed sum of M + 1 sinusoids. It is cheap and smooth, but deterministic and not stationary, and its correlation leaves J0 at large lags.
- Time
- O(M T) worst
- Space
- O(M) extra
- Where
- M = the number of oscillators minus one; T = the number of output samples
- Model
- Real RAM
- Properties
- deterministicnot exact clarke statisticsnot wide sense stationary
- Evidence
- Proof sketchCode in 1 languages
- Origin
- William C. Jakes, 1974
The Jakes simulator is a deterministic generator of a complex fading gain that approximates Clarke's model: it adds sinusoids whose frequencies are the Doppler shifts of plane waves at equally spaced angles. Clarke's model is the target statistics, the autocorrelation and the U-shaped Doppler spectrum; this page is about one way to produce a waveform with those statistics. The Zheng-Xiao simulator adds random angles and phases and gets the second-order statistics exactly, and the filtered Gaussian noise simulator shapes Gaussian noise with the spectrum instead of adding sinusoids. The Jakes simulator is a heuristic: it is smooth and cheap, but one run is a fixed function of time, not a random process with the statistics of Clarke's model.
In plain words
A receiver moving through a city gets the same signal along many paths. Each path arrives from its own direction, so the motion shifts its frequency by a different amount, and the paths add up to a gain that rises and falls in time. Jakes imagined a ring of equally spaced paths around the receiver. By symmetry, many of them have the same frequency shift, so only a few oscillators are needed. Each oscillator is a cosine at one Doppler shift, and fixed weights spread the oscillators over the real and imaginary parts of the gain. The sum fades in a way that looks like real fading over short times. But nothing in it is random: every run starts with the same high peak and gives the same waveform.
The problem
The input is the maximum Doppler shift in Hz, the mean power , the number of oscillators , and a list of times . The output is the gain at each time. The goal is that the time-average power is and that the time-average autocorrelation is close to , the autocorrelation of Clarke's model. The model is flat fading that varies in time (time-correlated fading); the simulator produces the channel only and says nothing about CSIR or CSIT.
The algorithm
JAKES(M, f_D, Ω, t)- 1
N ← 4M + 2 - 2
ν₀ ← 1; νₙ ← cos(2πn/N) for n = 1 .. M ▷ ωₙ = 2π f_D νₙ - 3
β₀ ← π/4; βₙ ← πn/M for n = 1 .. M - 4
a₀ ← √2 cos β₀, b₀ ← √2 sin β₀; aₙ ← 2 cos βₙ, bₙ ← 2 sin βₙ - 5
c ← Σ_{n=0}^{M} aₙ cos(ωₙ t) - 6
s ← Σ_{n=0}^{M} bₙ cos(ωₙ t) - 7
return √(2Ω/N) (c + j s)
Line L1 fixes the number of plane waves. The wave at angle has the Doppler shift . Because is odd, the waves at angles and give the same cosine up to sign, so the waves fold into the oscillators of line L2 plus the oscillator at itself. Lines L3 and L4 are the gains of Jakes, in the form of eqs. (6) and (7) of Zheng and Xiao (2003). The angles are chosen so that the two quadratures and have equal power: for . Lines L5 and L6 add the oscillators, and line L7 scales the sum so that the time-average power is .
Example
Take , so , and . The normalized frequencies are 1, 0.983, 0.9325, 0.8502, 0.739, 0.6026, 0.4457, 0.2737 and 0.0923. The gains are and .
The time-average autocorrelation of the output, divided by , is
| 0.1 | 0.25 | 0.5 | 1 | 2 | 3 | 5 | 10 | |
|---|---|---|---|---|---|---|---|---|
| 0.90371 | 0.47200 | -0.30424 | 0.22028 | 0.15751 | 0.12906 | 0.10025 | 0.07103 | |
| Jakes, | 0.90371 | 0.47200 | -0.30424 | 0.22028 | 0.15751 | 0.12906 | -0.00301 | -0.04948 |
Up to the two agree to five digits. The first lag where they differ by more than 0.01 is , and at the simulator has lost the correlation completely. With the same error appears at , and with at .
The quadratures are worse. At , the first zero of , each of and should have zero correlation with itself and with the other. The simulator gives 0.173 for , -0.173 for and -0.346 between them. Even at the quadratures are correlated, with coefficient .
At every cosine equals 1, so . Here and , so , a peak that a Rayleigh gain reaches with probability . Every run starts with it.
Correctness
Claim. The time-average power of the output is , and its time-average autocorrelation is above. is the -point trapezoid rule for , and exactly. So the error is small while is well below .
Key step. For distinct frequencies the time average of is if and 0 otherwise, and is 2 for and 4 otherwise. By the Jacobi-Anger expansion, is plus harmonics with weights . The average over equally spaced angles keeps only the harmonics that are multiples of , and the folding of line L2 turns that average into . The full proof is in the proofs folder. It also shows why the simulator is not wide-sense stationary: nothing in it is random, so the only "expectation" of is the product itself, and that product depends on .
Proof: The Jakes simulator has time-average power Omega, and its time-average autocorrelation is the N-point trapezoid rule for J0full
Let , , and for , with the gains of line L4. The output is
For a function , write for the time average.
Lemma 1 (distinct frequencies). For the frequencies are distinct and positive.
Proof. The angles for lie in , because . The cosine is strictly decreasing and positive there.
Lemma 2 (time averages of products). For , is if and otherwise.
Proof. The product is . The time average of is for , because its integral over is bounded by , and it is for .
Lemma 3 (the gains). , for , and .
Proof. The first two follow from . Next, , and . The last sum is for , because it is the real part of the sum of all -th roots of unity, so . For the sum is , and gives ; so the equal power holds for , and the same computation with sines gives for .
Theorem 1 (power and autocorrelation). For , , and
Proof. Expand the product into the double sum over of . By Lemmas 1 and 2, only survives the time average, and it gives . With Lemma 3 and the factor this is , which is . At , .
Lemma 4 (folding). .
Proof. The term gives , and so does , because and the cosine is even. The terms and are equal. For , the term has , so it is equal to the term . So the indices other than form groups of four equal terms, and the sum is . Divide by .
Theorem 2 (the error). .
Proof. The Jacobi-Anger expansion gives , and the series converges absolutely and uniformly in . Average it over , . The average of is 1 if divides and 0 otherwise. Since is even, means with , and because is odd. By Lemma 4 the average is .
Since , the error term is tiny while is well below : for , the difference from stays below up to . When approaches , is no longer small, and the error is of the size of itself.
Remark (no stationarity). is a fixed function of . A wide-sense stationary process needs to be independent of , and here the only expectation is the value itself. For example, , with and , which is for , while . With independent uniform phases added to the oscillators, is for and 0 otherwise, so the same computation as in Theorem 1 gives the ensemble autocorrelation for every : this is the variant of Pop and Beaulieu.
Complexity
Lines L1 to L4 cost once. Each output sample costs cosines and multiplications, so samples cost in the real RAM, with extra space. In hardware, each oscillator is a phase accumulator and a table lookup, which is why the method was popular for fading hardware.
Properties
- Not random. One run is a fixed function of time. Averages over a run converge to the values above, but there is no ensemble to average over, and the run is not wide-sense stationary (Pop and Beaulieu 2001).
- Second-order statistics. The complex autocorrelation matches for small lags only. The quadrature autocorrelations and the cross-correlation do not match Clarke's model at any .
- Higher-order statistics. The envelope is not exactly Rayleigh, and the level crossing rate and the fade durations are only close to those of Clarke's model for large .
- Smooth output. Unlike a filtered noise generator, it can be evaluated at any real time, and the waveform has no edge effects or periodic wrap.
- Equal power in each quadrature. The choice of gives , which is the purpose of line L3.
Variants and improvements
- Random phases. Pop and Beaulieu add a random phase to each oscillator. Over the random phases, the process is wide-sense stationary with the autocorrelation , but its higher-order statistics remain wrong.
- Several uncorrelated waveforms. Jakes shifted the angles for each waveform to get several fading gains from one set of oscillators, but these waveforms are not uncorrelated. Dent, Bottomley and Croft (1993) take the gains from the rows of a Walsh-Hadamard matrix, as in the Walsh-Hadamard transform, and change the arrival angles, so that the waveforms are uncorrelated.
- Random angles. The Zheng-Xiao simulator draws the arrival angles and phases at random. Its second-order statistics equal those of Clarke's model exactly, for any .
- Filtered noise. The filtered Gaussian noise simulator gives a Gaussian process with a spectrum close to Clarke's, at the cost of a block length fixed in advance.
When to use it
Use the Jakes simulator for a quick, smooth fading waveform, to look at fades or to drive hardware, when exact statistics are not important. Do not use it for Monte Carlo estimates of error rates or outage, which average over many independent channels: one run has no randomness, and runs that differ only in the start time are strongly dependent. For those, use the Zheng-Xiao simulator with a new draw per channel, or the filtered Gaussian noise simulator.
Pitfalls
- Calling it Clarke's model. The name "Jakes model" is used both for this generator and for the spectrum of Clarke's model. The spectrum is exact physics under its assumptions; the generator is an approximation.
- Averaging over runs. Running the simulator twice gives the same waveform. Shifting the start time gives different numbers, but not independent channels.
- The peak at . Every run starts with for . Discard the start, or use random phases.
- Long records. For near the correlation is wrong, and the waveform is almost periodic. Long simulations need larger .
- Quadrature statistics. Code that uses and as two independent real Gaussian processes, for example for two branches of a diversity system, gets correlated branches.
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/jakes-fading-simulator/. The authors are listed in prov/43NN0S.jsonl.
"""The Jakes simulator: a deterministic sum of sinusoids for Rayleigh fading.
Clarke's model has the autocorrelation Omega J0(2 pi f_D tau). The Jakes
simulator approximates it with N = 4M + 2 plane waves at the equally spaced
angles 2 pi n / N. By symmetry only M + 1 oscillators are needed: the
frequencies w_0 = 2 pi f_D and w_n = 2 pi f_D cos(2 pi n / N), n = 1..M,
with the gains a_n = 2 cos(beta_n), b_n = 2 sin(beta_n), beta_n = pi n / M,
and a_0 = b_0 = 1 (sqrt(2) cos(pi / 4)). The form follows eqs. (6) and (7) of
Zheng and Xiao 2003. With the factor sqrt(2 Omega / N), the time-average
power is Omega.
The optional phases (one per oscillator) give the variant with random
phases of Pop and Beaulieu 2001, which is wide-sense stationary over the
ensemble of phases.
"""
import math
def jakes_coefficients(m: int) -> tuple[int, list[float], list[float], list[float]]:
"""N, the normalized frequencies cos(2 pi n / N) and the gains a_n, b_n for n = 0..M."""
if m < 1:
raise ValueError("need M >= 1")
n = 4 * m + 2 # @line L1
nu = [1.0] + [math.cos(2.0 * math.pi * k / n) for k in range(1, m + 1)] # @line L2
beta = [math.pi / 4.0] + [math.pi * k / m for k in range(1, m + 1)] # @line L3
a = [math.sqrt(2.0) * math.cos(beta[0])] + [2.0 * math.cos(x) for x in beta[1:]] # @line L4
b = [math.sqrt(2.0) * math.sin(beta[0])] + [2.0 * math.sin(x) for x in beta[1:]]
return n, nu, a, b
def jakes(m: int, fd: float, times: list[float], omega: float = 1.0, phases: list[float] | None = None) -> list[complex]:
"""The fading gains h(t) of the Jakes simulator with M + 1 oscillators at the given times.
fd is the maximum Doppler shift in Hz and times are in seconds. phases, if
given, holds M + 1 oscillator phases (the variant of Pop and Beaulieu).
"""
n, nu, a, b = jakes_coefficients(m)
if phases is None:
phases = [0.0] * (m + 1)
if len(phases) != m + 1:
raise ValueError("need M + 1 phases")
w = [2.0 * math.pi * fd * v for v in nu]
g = math.sqrt(2.0 * omega / n)
out = []
for t in times:
osc = [math.cos(w[k] * t + phases[k]) for k in range(m + 1)]
c = sum(a[k] * osc[k] for k in range(m + 1)) # @line L5
s = sum(b[k] * osc[k] for k in range(m + 1)) # @line L6
out.append(g * complex(c, s)) # @line L7
return out
def time_autocorrelation(m: int, x: float) -> float:
"""The time-average autocorrelation <h(t + tau) conj(h(t))> / Omega at x = 2 pi f_D tau.
It is (2 / N) (cos x + 2 sum_{n=1}^{M} cos(x cos(2 pi n / N))), the N-point
trapezoid rule for J0(x).
"""
n, nu, _, _ = jakes_coefficients(m)
return (2.0 / n) * (math.cos(x) + 2.0 * sum(math.cos(x * v) for v in nu[1:]))
def quadrature_correlations(m: int, x: float) -> tuple[float, float, float]:
"""The time-average correlations <c c>, <s s> and <c s> of the two quadratures, each normalized by the power of one quadrature."""
n, nu, a, b = jakes_coefficients(m)
rcc = (2.0 / n) * sum(a[k] ** 2 * math.cos(x * nu[k]) for k in range(m + 1))
rss = (2.0 / n) * sum(b[k] ** 2 * math.cos(x * nu[k]) for k in range(m + 1))
rcs = (2.0 / n) * sum(a[k] * b[k] * math.cos(x * nu[k]) for k in range(m + 1))
return rcc, rss, rcs
def bessel_j(order: int, x: float, points: int = 2048) -> float:
"""J_n(x) = (1 / 2 pi) integral over [0, 2 pi) of cos(n t - x sin t) dt, by the trapezoid rule.
The integrand is periodic and smooth, so the rule converges very fast when
points is well above order + |x|.
"""
h = 2.0 * math.pi / points
return sum(math.cos(order * k * h - x * math.sin(k * h)) for k in range(points)) / points
def j0(x: float) -> float:
"""The Bessel function J0(x)."""
return bessel_j(0, x)
def aliasing_series(m: int, x: float, terms: int = 4) -> float:
"""J0(x) + 2 sum_{k>=1} (-1)^k J_{kN}(x), the exact value of the Jakes autocorrelation."""
n = 4 * m + 2
return j0(x) + 2.0 * sum((-1) ** k * bessel_j(k * n, x) for k in range(1, terms + 1))
def power_at_zero(m: int) -> float:
"""|h(0)|^2 / Omega for zero phases: (2 / N) ((sum a)^2 + (sum b)^2)."""
n, _, a, b = jakes_coefficients(m)
return (2.0 / n) * (sum(a) ** 2 + sum(b) ** 2)
test_jakes_fading_simulator.py 122 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/jakes-fading-simulator/. The authors are listed in prov/43NN0S.jsonl.
import math
import random
from jakes_fading_simulator import (
aliasing_series,
bessel_j,
j0,
jakes,
jakes_coefficients,
power_at_zero,
quadrature_correlations,
time_autocorrelation,
)
M = 8
FD = 1.0
STEP = 0.05
RECORD = 2000.0
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 record():
times = [k * STEP for k in range(int(RECORD / STEP))]
return jakes(M, FD, times)
def test_coefficients() -> None:
n, nu, a, b = jakes_coefficients(M)
assert n == 34
assert len(nu) == len(a) == len(b) == M + 1
assert abs(a[0] - 1.0) < 1e-12 and abs(b[0] - 1.0) < 1e-12
# time-average powers of the two quadratures are equal: sum a^2 = sum b^2 = N / 2
assert abs(sum(v * v for v in a) - n / 2) < 1e-12
assert abs(sum(v * v for v in b) - n / 2) < 1e-12
def test_bessel_against_series() -> None:
for x in (0.0, 0.5, 1.0, 2.404825557695773, 5.0, 10.0):
assert abs(j0(x) - j0_series(x)) < 1e-10
assert abs(j0(2 * math.pi * 0.38274)) < 1e-4 # the first zero of J0 at f_D tau = 0.38274
def test_mean_power() -> None:
h = record()
p = sum(abs(v) ** 2 for v in h) / len(h)
assert abs(p - 1.0) < 0.02
def test_sample_autocorrelation_matches_closed_form() -> None:
h = record()
for lag in (2, 5, 8, 20, 40): # f_D tau = 0.1, 0.25, 0.4, 1, 2
r = sum(h[k + lag] * h[k].conjugate() for k in range(len(h) - lag)) / (len(h) - lag)
x = 2 * math.pi * FD * lag * STEP
assert abs(r - time_autocorrelation(M, x)) < 0.02
assert abs(r - j0(x)) < 0.02
def test_closed_form_close_to_clarke_for_small_lags() -> None:
for k in range(0, 301):
x = 2 * math.pi * k * 0.01 # f_D tau up to 3
assert abs(time_autocorrelation(M, x) - j0(x)) < 1e-3
def test_bias_at_large_lags() -> None:
# f_D tau = 5 and 10: the autocorrelation departs from J0
for ft, target in ((5.0, -0.00301), (10.0, -0.04948)):
x = 2 * math.pi * ft
r = time_autocorrelation(M, x)
assert abs(r - target) < 1e-4
assert abs(r - j0(x)) > 0.05
assert abs(r - aliasing_series(M, x)) < 1e-9
def test_quadratures_are_not_clarke() -> None:
x = 2 * math.pi * 0.38274 # J0 is zero here
rcc, rss, rcs = quadrature_correlations(M, x)
assert abs(rcc - 0.17328) < 1e-4
assert abs(rcs - (-0.3462)) < 1e-4
assert abs(rcc + rss - 2 * time_autocorrelation(M, x)) < 1e-12
rcc0, rss0, rcs0 = quadrature_correlations(M, 0.0)
assert abs(rcc0 - 1) < 1e-12 and abs(rss0 - 1) < 1e-12
assert abs(rcs0 - 2 / 34) < 1e-12 # the quadratures are correlated at lag 0
def test_peak_at_time_zero() -> None:
h0 = jakes(M, FD, [0.0])[0]
expect = (2 / 34) * (1 + (1 + 2 / math.tan(math.pi / 16)) ** 2)
assert abs(abs(h0) ** 2 - expect) < 1e-9
assert abs(power_at_zero(M) - expect) < 1e-9
assert 7.2 < expect < 7.3
def test_random_phases_give_unit_ensemble_power() -> None:
rng = random.Random(4301)
trials = 4000
acc0 = 0.0
acc1 = 0j
x = 2 * math.pi * 0.25
for _ in range(trials):
ph = [rng.uniform(-math.pi, math.pi) for _ in range(M + 1)]
a, b = jakes(M, FD, [0.0, 0.25], phases=ph)
acc0 += abs(a) ** 2
acc1 += b * a.conjugate()
assert abs(acc0 / trials - 1.0) < 0.06
assert abs(acc1 / trials - time_autocorrelation(M, x)) < 0.06
def test_bessel_order() -> None:
# J1(1) = 0.44005058574493355
assert abs(bessel_j(1, 1.0) - 0.44005058574493355) < 1e-12
History
Jakes and his colleagues at Bell Labs built fading simulators from banks of oscillators in the early 1970s, and the 1974 book Microwave Mobile Communications, which Jakes edited, gave the design with waves and oscillators. It became the standard way to simulate fading for two decades. Dent, Bottomley and Croft (1993) changed the gains to produce several uncorrelated waveforms. Pop and Beaulieu (2001) showed that the simulator and its variants are not wide-sense stationary and proposed random phases. Zheng and Xiao (2002, 2003) then gave statistical sum-of-sinusoids models with random angles, whose second-order statistics match Clarke's model.
References
- William C. Jakes (editor), Microwave Mobile Communications, Wiley, 1974; reissued by IEEE Press, 1994, Chapter 1 (the laboratory simulation of multipath fading with equally spaced oscillators)
- 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 proof that the Jakes simulator is not wide-sense stationary, and the variant with random oscillator phases
- 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, eqs. (6) and (7) (the Jakes simulator in the form used here) and its statistics against Clarke's model
- P. Dent, G. E. Bottomley and T. Croft, Jakes fading model revisited, Electronics Letters 29(13), 1993, pages 1162 to 1163, the variant with Walsh-Hadamard weights for several uncorrelated waveforms
Where this leads
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 43NN0S Edit this page History Report an error Markdown