Algorithmcore
Truncated channel inversion
Also called channel inversion power control.
Power policy for a fading channel: send nothing below a cutoff SNR, and above it send power inversely proportional to the channel, so the receiver sees a constant SNR and a fixed-rate code works.
- Time
- O(K log K) worst
- Space
- O(K) extra
- Where
- K = the number of channel states
- Model
- Real RAM
- Properties
- deterministicfixed rateneeds csitnot optimal
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Andrea J. Goldsmith, Pravin P. Varaiya, 1997
Truncated channel inversion is a power policy for a fading channel whose gain the transmitter knows. Let be the SNR that the receiver would see at the average power . When is below a cutoff , the transmitter sends nothing. Otherwise it sends the power , the inverse of the channel, so the received SNR is the constant . The average power limit fixes , and a single code for the AWGN channel at SNR then gives the rate . The cutoff is chosen to maximize this rate. Without truncation (), channel inversion has zero rate on Rayleigh fading, since is infinite there. Goldsmith and Varaiya (1997) compared it with water-filling over time, which is optimal: inversion is simple and keeps one fixed rate, and on Rayleigh fading it loses about a third to two thirds of a bit against water-filling between 10 and 20 dB.
In plain words
A wireless channel gets stronger and weaker all the time. If the sender knows how strong it is, it can push more power when the channel is weak and less when it is strong. Then the receiver always gets the same signal level, and one simple fixed code works all the time.
The trouble is that a very weak channel needs a huge amount of power to fix. So the sender gives up when the channel is too weak and sends nothing then. The level at which it gives up is a trade-off: give up too often and little time is used, give up too rarely and power is wasted on bad moments.
The problem
The SNR is random with a known distribution, and the transmitter knows its current value. A policy must satisfy . Truncated inversion uses the received SNR in every state with and nothing else; given the cutoff, the largest such is with . The task is to find that maximizes . For a distribution with states, such as a quantized channel or a measured sample, the best cutoff is one of the states.
The algorithm
The states are with probabilities (equal values merged first).
TRUNCATED-INVERSION(γ[1..K], π[1..K])- 1
sort the states so that γ[1] > γ[2] > .. > γ[K] - 2
S ← 0, Q ← 0, best ← (0, none, none) - 3
for k = 1 to K do ▷ serve the k strongest states - 4
S ← S + π_k / γ_k, Q ← Q + π_k ▷ S = E[1/γ; γ ≥ γ_k], Q = Pr(γ ≥ γ_k) - 5
R ← Q · log2(1 + 1/S) - 6
if R > best rate then best ← (R, γ_k, 1/S) - 7
(R, γ0, σ) ← best - 8
return γ0, σ, R, and P(γ)/P̄ = σ/γ for γ ≥ γ0, 0 otherwise
For Rayleigh fading with mean SNR , the sums have the closed form and , where is the exponential integral, and the best cutoff is found by a one-dimensional search.
Example
Four states. Let , each with probability .
| served states | rate | |||
|---|---|---|---|---|
| 8 | 0.03125 | 32.000 | 0.25 | 1.2611 |
| 8, 4 | 0.09375 | 10.667 | 0.50 | 1.7722 |
| 8, 4, 2 | 0.21875 | 4.571 | 0.75 | 1.8585 |
| 8, 4, 2, 0.5 | 0.71875 | 1.391 | 1.00 | 1.2578 |
The best cutoff is , with (6.60 dB) and the rate 1.8585 bits per channel use. The powers are for , and their mean is 1. Full inversion, the last row, must spend most of its power on the state and gets only 1.2578.
Rayleigh fading. For Rayleigh fading with mean SNR , compare the best truncated inversion with the ergodic capacity without transmitter knowledge, , with water-filling over time, and with an AWGN channel at the same mean SNR (values computed by the test code):
| best | outage | truncated inversion | no CSIT | water-filling | AWGN | ||
|---|---|---|---|---|---|---|---|
| 0 dB | -1.21 dB | 0.531 | 4.74 dB | 0.934 | 0.860 | 1.029 | 1.000 |
| 5 dB | 1.82 dB | 0.382 | 7.34 dB | 1.658 | 1.716 | 1.845 | 2.057 |
| 10 dB | 4.80 dB | 0.261 | 10.45 dB | 2.660 | 2.907 | 2.979 | 3.459 |
| 20 dB | 11.18 dB | 0.123 | 18.01 dB | 5.267 | 5.884 | 5.896 | 6.658 |
At 10 dB the policy gives up in 26% of the time and loses 0.32 bits against water-filling. At low SNR it beats the rate without transmitter knowledge, because it moves power to the good states.
Correctness
Claim. The policy returned uses the average power exactly , gives the received SNR in every state it serves, and its cutoff maximizes over all .
Key steps. With on the served states, the mean power is , so uses the budget exactly, and no larger constant SNR fits. For a discrete distribution, every cutoff serves some set of the strongest states, and the rate depends only on that set, so the cutoffs at the states cover all cases. The loop keeps and as running sums over the strongest states, so line L5 computes each candidate rate exactly once, and line L6 keeps the largest. The full proof is in the proofs folder.
Proof: Truncated channel inversion meets the power constraint, holds the received SNR constant, and the scan finds the best cutofffull
Setting. The channel SNR at the average power is a random variable . A power policy must satisfy , and in state the received SNR is . For a cutoff , let
Assume , so that . Truncated channel inversion with cutoff is the policy
and its rate is bits per channel use: a fixed code for the AWGN channel with SNR is used whenever .
Lemma 1 (power and received SNR). The policy uses the average power exactly , the received SNR is in every state with , and no policy that sends nothing below and gives the same received SNR in every state with within the power has .
Proof. . In a state with , the received SNR is . A policy with received SNR on the same states must use there, so its average power is , and gives .
Lemma 2 (finitely many candidates). Let take the distinct values with probabilities . For put and , and . Then .
Proof. For with (with ), the event is the event that is one of , so and , and . For , . These intervals cover , and the choice gives .
Lemma 3 (the scan). After the pass of lines L3 to L6 for the -th state in sorted order, , , and the stored best rate is , stored with its cutoff and for the first that attains it.
Proof. Line L1 merges equal values, adding their probabilities, and sorts the distinct values in decreasing order. Before the first pass, and the best rate is 0. Line L4 adds and , which gives and from and . Line L5 computes , and line L6 keeps it if it is larger than all earlier ones. Every , so the first pass always stores its state.
Theorem. For a discrete distribution, TRUNCATED-INVERSION returns a cutoff that maximizes over all , the value , the rate , and the power of each state, and this policy uses the average power and gives the constant received SNR in every state it serves.
Proof. By Lemma 3, after the last pass the stored rate is , which by Lemma 2 is the largest rate over all cutoffs. Its cutoff is and its is . Line L8 sets for and 0 otherwise, which is the policy of Lemma 1.
Remark (the Rayleigh closed form). For Rayleigh fading, has the density , so with ,
and . So and . As , and ; this is why full inversion has zero rate on Rayleigh fading. As , faster than grows, so . The function is continuous, so a best cutoff exists, and the implementation finds it by a grid on a log scale followed by a golden section search.
Remark (what the theorem does not say). The theorem is about threshold policies, which is what truncated channel inversion means. Among all policies with a constant received SNR on the served states, serving part of a state at random can do better on a discrete distribution. For a fixed served probability , the cost is least when the served probability sits on the largest values of , as in the fractional knapsack problem, so the best such policy serves the top states and a fraction of one more. For a continuous distribution this fraction has no effect, and the threshold policy is the best of this class. Policies whose received SNR varies with can do better still: water-filling over time attains the capacity with side information at both ends, and is at most that capacity.
Complexity
In the real RAM, line L1 sorts in time, and the loop does work per state, so the time is and the extra space is . When the states arrive sorted, as in a table of quantized SNR levels, the time is . For a continuous distribution with a closed form such as Rayleigh, each evaluation of costs one evaluation of , and a golden section search needs about evaluations. The policy is computed once per channel distribution; at run time it costs one division per channel state.
Properties
- Constant received SNR. One fixed code and one fixed modulation work in every served state. This is its main practical advantage over water-filling, which needs a different rate in each state.
- Zero rate without truncation on Rayleigh fading. for the exponential distribution, so full inversion has . Diversity changes this: with branches of maximal ratio combining, is finite.
- Not capacity-achieving. It spends the most power where the channel is weakest, the reverse of water-filling. Its rate is at most the water-filling capacity, which is at most by Jensen's inequality.
- Outage. The cutoff sets the outage probability , which is 0.261 at the best cutoff for Rayleigh fading at 10 dB. A delay-sensitive service can fix the outage first and accept the rate it gets; this is the outage capacity.
- Sensitive to estimation errors. A deep fade that the transmitter misreads leads to large power errors near the cutoff.
Variants and improvements
- Full channel inversion. , the zero-outage capacity . It is useful only when is small, for example with diversity.
- Fixed outage. Choose so that instead of maximizing the rate.
- Discrete rates. Adaptive modulation changes the constellation with instead of holding the SNR constant. Combined forms invert the channel inside each region of a constellation, so the received SNR is just at the threshold of the constellation in use.
- Water-filling over time. with a variable rate attains the capacity with side information at both ends; see water-filling.
- Closed-loop power control. Cellular uplinks, such as CDMA, use fast power control steps to keep the received SNR near a target. This is a form of channel inversion that also solves the near-far problem; an outer loop moves the target.
When to use it
Use it when the transmitter knows the channel, the codec or the service wants a fixed rate, and a small outage is acceptable, as for voice. When the rate may vary, adaptive modulation or water-filling gives more. On channels with strong diversity, the loss from inversion is small, and full inversion without truncation may be enough.
Pitfalls
- Inverting without a cutoff on Rayleigh fading. The required mean power is unbounded; a simulation with a finite sample hides this and shows a rate that falls as the sample grows.
- Using the received SNR in place of the channel SNR. is the SNR at the average power, before the policy changes the power.
- Peak power. Near the cutoff the power is , which can be several times the mean. A real amplifier limits this, and the analysis must include the limit.
- dB values. The sums use linear SNR values.
- Cutoffs between states. For a discrete distribution, a cutoff between two states is the same as the next state above it; searching a fine grid wastes time without changing the answer.
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/truncated-channel-inversion/. The authors are listed in prov/PEF750.jsonl.
"""Truncated channel inversion over a fading channel.
gamma is the SNR the receiver would see at the average power. Truncated
channel inversion sends nothing when gamma < gamma0 and otherwise sends the
power P(gamma) / Pbar = sigma / gamma, so the received SNR is the constant
sigma. The average power constraint gives sigma = 1 / E[1/gamma; gamma >= gamma0],
and the rate is log2(1 + sigma) * Pr(gamma >= gamma0) bits per channel use.
truncated_inversion() works on a discrete distribution of states (for
example a quantized channel or an empirical sample) and finds the best cutoff
among the states in O(K log K). The Rayleigh functions use the closed form
sigma = gbar / E1(gamma0 / gbar) and Pr = exp(-gamma0 / gbar).
"""
import math
EULER_GAMMA = 0.5772156649015329
def truncated_inversion(gammas, probs=None):
"""Best cutoff for states gammas[k] > 0 with probabilities probs[k].
Returns (gamma0, sigma, rate, powers), where powers[k] is P / Pbar in state k.
probs defaults to equal weights (an empirical sample).
"""
if not gammas or any(not g > 0 for g in gammas):
raise ValueError("need at least one state and positive SNR values")
if probs is None:
probs = [1 / len(gammas)] * len(gammas)
if len(probs) != len(gammas) or any(p < 0 for p in probs) or abs(sum(probs) - 1) > 1e-9:
raise ValueError("probs must be a probability vector of the same length")
merged = {}
for g, p in zip(gammas, probs):
merged[g] = merged.get(g, 0.0) + p
states = sorted(((g, p) for g, p in merged.items() if p > 0), reverse=True) # @line L1
s, q, best = 0.0, 0.0, (0.0, None, None) # @line L2
for g, p in states: # @line L3
s, q = s + p / g, q + p # @line L4
rate = q * math.log2(1 + 1 / s) # @line L5
if rate > best[0]: # @line L6
best = (rate, g, 1 / s)
rate, gamma0, sigma = best # @line L7
powers = [sigma / g if g >= gamma0 else 0.0 for g in gammas]
return gamma0, sigma, rate, powers # @line L8
def zero_outage_rate(gammas, probs=None):
"""Full channel inversion: log2(1 + 1 / E[1/gamma])."""
if probs is None:
probs = [1 / len(gammas)] * len(gammas)
return math.log2(1 + 1 / sum(p / g for g, p in zip(gammas, probs)))
def expint_e1(x: float) -> float:
"""The exponential integral E1(x) for x > 0."""
if not x > 0:
raise ValueError("E1 needs x > 0")
if x <= 1:
total, term, k = -EULER_GAMMA - math.log(x), 1.0, 1
while True:
term *= -x / k
add = -term / k
total += add
if abs(add) < 1e-17 * abs(total):
return total
k += 1
# Continued fraction (modified Lentz), valid for x > 0, fast for x >= 1.
tiny = 1e-300
b = x + 1
c = 1 / tiny
d = 1 / b
h = d
for i in range(1, 1000):
a = -i * i
b += 2
d = 1 / (a * d + b)
c = b + a / c
delta = c * d
h *= delta
if abs(delta - 1) < 1e-16:
break
return h * math.exp(-x)
def rayleigh_rate(gamma0: float, gbar: float) -> float:
"""Rate of truncated inversion with cutoff gamma0 on Rayleigh fading with mean SNR gbar."""
if not gamma0 > 0 or not gbar > 0:
raise ValueError("need gamma0 > 0 and gbar > 0")
x = gamma0 / gbar
sigma = gbar / expint_e1(x)
return math.log2(1 + sigma) * math.exp(-x)
def rayleigh_best_cutoff(gbar: float, iters: int = 200) -> tuple[float, float]:
"""(gamma0, rate) of the best cutoff on Rayleigh fading: a log grid, then golden section."""
grid = [gbar * 10 ** (e / 20) for e in range(-120, 41)]
k = max(range(len(grid)), key=lambda j: rayleigh_rate(grid[j], gbar))
lo = math.log(grid[max(k - 1, 0)])
hi = math.log(grid[min(k + 1, len(grid) - 1)])
r = (math.sqrt(5) - 1) / 2
for _ in range(iters):
a, b = hi - r * (hi - lo), lo + r * (hi - lo)
if rayleigh_rate(math.exp(a), gbar) < rayleigh_rate(math.exp(b), gbar):
lo = a
else:
hi = b
g0 = math.exp((lo + hi) / 2)
return g0, rayleigh_rate(g0, gbar)
test_truncated_channel_inversion.py 134 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/truncated-channel-inversion/. The authors are listed in prov/PEF750.jsonl.
import math
import random
import pytest
from truncated_channel_inversion import (
expint_e1,
rayleigh_best_cutoff,
rayleigh_rate,
truncated_inversion,
zero_outage_rate,
)
def top_k_rates(gammas, probs):
states = sorted(zip(gammas, probs), reverse=True)
out, s, q = [], 0.0, 0.0
for g, p in states:
s, q = s + p / g, q + p
out.append(q * math.log2(1 + 1 / s))
return out
def water_filling_rate(gammas, probs):
"""Capacity with the SNR known at both ends: P(g)/Pbar = max(0, 1/g0 - 1/g)."""
lo, hi = 1e-12, max(gammas) * 1e6
for _ in range(300):
mid = math.sqrt(lo * hi)
power = sum(p * max(0.0, 1 / mid - 1 / g) for g, p in zip(gammas, probs))
lo, hi = (lo, mid) if power < 1 else (mid, hi)
g0 = math.sqrt(lo * hi)
return sum(p * math.log2(g / g0) for g, p in zip(gammas, probs) if g > g0)
def test_page_example() -> None:
gamma0, sigma, rate, powers = truncated_inversion([0.5, 2, 4, 8], [0.25] * 4)
assert gamma0 == 2 and abs(sigma - 32 / 7) < 1e-12
assert abs(rate - 0.75 * math.log2(1 + 32 / 7)) < 1e-12
assert abs(rate - 1.858535) < 1e-6
assert powers == [0.0, 16 / 7, 8 / 7, 4 / 7]
assert [round(r, 4) for r in top_k_rates([0.5, 2, 4, 8], [0.25] * 4)] == [1.2611, 1.7722, 1.8585, 1.2578]
assert abs(zero_outage_rate([0.5, 2, 4, 8]) - 1.257798) < 1e-6
def test_power_and_constant_received_snr() -> None:
rng = random.Random(51)
for _ in range(300):
k = rng.randint(1, 30)
gammas = [rng.expovariate(1 / 10) + 1e-3 for _ in range(k)]
w = [rng.random() + 1e-3 for _ in range(k)]
probs = [x / sum(w) for x in w]
gamma0, sigma, rate, powers = truncated_inversion(gammas, probs)
assert abs(sum(p * x for p, x in zip(probs, powers)) - 1) < 1e-9
for g, x in zip(gammas, powers):
if g >= gamma0:
assert abs(g * x - sigma) < 1e-9 * sigma
else:
assert x == 0
served = sum(p for g, p in zip(gammas, probs) if g >= gamma0)
assert abs(rate - served * math.log2(1 + sigma)) < 1e-12
assert abs(rate - max(top_k_rates(gammas, probs))) < 1e-12
def test_rate_lies_between_the_bounds() -> None:
rng = random.Random(52)
for _ in range(100):
k = rng.randint(1, 40)
gammas = [rng.expovariate(1 / 20) + 1e-2 for _ in range(k)]
probs = [1 / k] * k
_, _, rate, _ = truncated_inversion(gammas, probs)
assert rate >= zero_outage_rate(gammas, probs) - 1e-12
assert rate <= water_filling_rate(gammas, probs) + 1e-9
assert water_filling_rate(gammas, probs) <= math.log2(1 + sum(gammas) / k) + 1e-9
def test_ties_are_merged() -> None:
a = truncated_inversion([2, 2, 8, 0.5], [0.125, 0.125, 0.25, 0.5])
b = truncated_inversion([2, 8, 0.5], [0.25, 0.25, 0.5])
assert a[:3] == b[:3]
def test_e1_values() -> None:
assert abs(expint_e1(1) - 0.21938393439552) < 1e-13
assert abs(expint_e1(0.1) - 1.8229239584193906) < 1e-13
assert abs(expint_e1(5) - 0.001148295591275) < 1e-15
assert abs(expint_e1(1e-4) - (-0.5772156649015329 - math.log(1e-4) + 1e-4)) < 1e-8
with pytest.raises(ValueError):
expint_e1(0)
def test_rayleigh_closed_form_against_integration() -> None:
gbar, gamma0 = 10.0, 3.0
n, top = 200000, 400.0
h = (top - gamma0) / n
total = 0.0
for i in range(n + 1):
g = gamma0 + i * h
w = 1 if i in (0, n) else (4 if i % 2 else 2)
total += w * math.exp(-g / gbar) / (gbar * g)
inv_mean = total * h / 3
expected = math.log2(1 + 1 / inv_mean) * math.exp(-gamma0 / gbar)
assert abs(rayleigh_rate(gamma0, gbar) - expected) < 1e-7
def test_rayleigh_check_values() -> None:
gamma0, rate = rayleigh_best_cutoff(10.0)
assert abs(rate - 2.6595) < 1e-4
assert abs(10 * math.log10(gamma0) - 4.80) < 0.01
ergodic = math.exp(0.1) * expint_e1(0.1) / math.log(2)
assert abs(ergodic - 2.9065) < 1e-4
assert rate < ergodic < math.log2(11)
for g0 in (gamma0 * 0.8, gamma0 * 1.25):
assert rayleigh_rate(g0, 10.0) < rate
def test_rayleigh_sample_matches_closed_form() -> None:
rng = random.Random(53)
sample = [rng.expovariate(1 / 10) for _ in range(40000)]
_, _, rate, _ = truncated_inversion(sample)
assert abs(rate - 2.6595) < 0.05
def test_bad_input() -> None:
with pytest.raises(ValueError):
truncated_inversion([])
with pytest.raises(ValueError):
truncated_inversion([1, 0])
with pytest.raises(ValueError):
truncated_inversion([1, 2], [0.5, 0.6])
with pytest.raises(ValueError):
rayleigh_rate(0, 1)
History
Channel inversion is the idea behind the power control of cellular CDMA systems, which keep the received power of every user at the same level. Goldsmith and Varaiya, in their 1997 paper on the capacity of fading channels with side information, derived the capacity when both ends know the channel, which uses water-filling in time, and compared it with the rates of channel inversion and truncated inversion, which keep the received SNR constant. On Rayleigh fading, inversion without truncation gives zero rate. Goldsmith's textbook calls the rate of channel inversion the zero-outage capacity and the rate of truncated inversion the outage capacity, and Tse and Viswanath make the same comparison with water-filling.
References
- Andrea J. Goldsmith and Pravin P. Varaiya, Capacity of fading channels with channel side information, IEEE Transactions on Information Theory 43(6), 1997, pages 1986 to 1992, the capacity with side information at both ends (water-filling in time), compared with the rates of channel inversion and truncated channel inversion
- Andrea Goldsmith, Wireless Communications, Cambridge University Press, 2005, Chapter 4 (capacity of fading channels: channel inversion, zero-outage capacity, truncated channel inversion and outage capacity)
- David Tse and Pramod Viswanath, Fundamentals of Wireless Communication, Cambridge University Press, 2005, Chapter 5 (fading channels with full channel side information, channel inversion compared with water-filling over time)
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 PEF750 Edit this page History Report an error Markdown