TExcelTAD
Home › Fourier Analysis & Signals › The Uncertainty Principle

The Uncertainty Principle

A signal cannot be both short in time and narrow in frequency. The scaling rule hinted at this; the uncertainty principle makes it exact: the product of a signal's spread in time and its spread in frequency is at least 1/(4π)1/(4\pi), with equality only for Gaussians. It limits every spectrogram, every radar and, in physics, the simultaneous knowledge of position and momentum.

Measuring spread

Treat ∣f(t)∣2/E\lvert f(t) \rvert^2 / E as a probability density in time and ∣f^(s)∣2/E\lvert \hat{f}(s) \rvert^2 / E as one in frequency (EE is the energy). Their standard deviations are the duration σt\sigma_t and the bandwidth σs\sigma_s:

σt2=1E∫(t−tˉ)2∣f(t)∣2dt,σs2=1E∫(s−sˉ)2∣f^(s)∣2ds\sigma_t^2 = \frac{1}{E}\int (t - \bar{t})^2 \lvert f(t) \rvert^2 dt, \qquad \sigma_s^2 = \frac{1}{E}\int (s - \bar{s})^2 \lvert \hat{f}(s) \rvert^2 ds

The Heisenberg-Gabor inequality states

σt σs≥14π\sigma_t \, \sigma_s \ge \frac{1}{4\pi}

The proof is the Cauchy-Schwarz inequality applied to tf(t)t f(t) and f′(t)f'(t), using f′^=2πisf^\widehat{f'} = 2\pi i s \hat{f}.

python · try it yourself
import numpy as np

dt = 0.001
t = np.arange(-20, 20, dt)

def spread(density, x, dx):
    p = density / (np.sum(density) * dx)
    m = np.sum(x * p) * dx
    return np.sqrt(np.sum((x - m) ** 2 * p) * dx)

def time_freq_product(f):
    F = np.fft.fftshift(np.fft.fft(f)) * dt               # samples of the transform
    s = np.fft.fftshift(np.fft.fftfreq(t.size, dt))
    return spread(np.abs(f) ** 2, t, dt) * spread(np.abs(F) ** 2, s, s[1] - s[0])

print("bound 1/(4 pi) =", round(1 / (4 * np.pi), 5))
for width in (0.5, 1, 3):
    g = np.exp(-np.pi * (t / width) ** 2)
    print(f"Gaussian, width {width}: product {time_freq_product(g):.5f}")
print(f"two-sided exponential: product {time_freq_product(np.exp(-np.abs(t))):.5f}")
print(f"triangle:              product {time_freq_product(np.clip(1 - np.abs(t), 0, None)):.5f}")
bound 1/(4 pi) = 0.07958
Gaussian, width 0.5: product 0.07958
Gaussian, width 1: product 0.07958
Gaussian, width 3: product 0.07958
two-sided exponential: product 0.11257
triangle:              product 0.08719

Gaussians of every width hit the bound exactly; other shapes are above it. (The FFT here is only a fast way to evaluate the transform at many frequencies; see The FFT in NumPy.)

The practical trade-off

To tell apart two tones Δf\Delta f Hz apart, you must observe the signal for roughly 1/Δf1/\Delta f seconds. A guitar tuner that must distinguish 440 Hz from 441 Hz needs about one second of sound; a spectrogram with 10 ms frames cannot resolve frequencies finer than about 100 Hz.

python · try it yourself
import numpy as np

fs = 1000
for duration in (0.25, 1.0, 4.0):
    t = np.arange(0, duration, 1 / fs)
    x = np.sin(2 * np.pi * 100 * t) + np.sin(2 * np.pi * 102 * t)
    X = np.abs(np.fft.rfft(x, n=1 << 16))                # zero-padded to evaluate on a fine grid
    f = np.fft.rfftfreq(1 << 16, 1 / fs)
    band = (f > 95) & (f < 107)
    Xb, fb = X[band], f[band]
    peaks = [fb[i] for i in range(1, len(Xb) - 1) if Xb[i] > Xb[i - 1] and Xb[i] > Xb[i + 1] and Xb[i] > 0.5 * Xb.max()]
    print(f"{duration:4} s of signal: peaks near 100-102 Hz at {np.round(peaks, 2).tolist()}")
0.25 s of signal: peaks near 100-102 Hz at [100.98]
 1.0 s of signal: peaks near 100-102 Hz at [99.87, 102.13]
 4.0 s of signal: peaks near 100-102 Hz at [99.99, 102.01]

With 0.25 s the two tones merge into one peak; with 1 s or more they separate.

In software

  • Choosing an STFT window length is choosing a point on this trade-off (The Short-Time Fourier Transform); wavelets choose different trade-offs at different frequencies.
  • Gabor's Gaussian-windowed atoms, which meet the bound, are used in time-frequency analysis and in the Gabor filters of early computer vision.

Exercises

Exercise 1: Minimal duration

A pulse must occupy a bandwidth σs\sigma_s of at most 1 kHz. What is the smallest possible duration σt\sigma_t?

Answer

About 80 microseconds.

Solution

σt≥1/(4πσs)=1/(4π⋅1000)≈7.96⋅10−5\sigma_t \ge 1/(4\pi \sigma_s) = 1/(4\pi \cdot 1000) \approx 7.96 \cdot 10^{-5} s, reached by a Gaussian pulse.

Exercise 2: Observation time

Roughly how long must you record to separate two tones 0.5 Hz apart?

Answer

About 2 seconds or more.

Solution

The frequency resolution is about 1/T1/T, so T≳1/0.5=2T \gtrsim 1/0.5 = 2 s. Windowing and noise make the real requirement somewhat larger.

Exercise 3: The rectangle's paradox (code)

Compute the time spread of the rectangle Π(t)\Pi(t). Why is its frequency spread σs\sigma_s infinite?

Answer

σt=1/12≈0.2887\sigma_t = 1/\sqrt{12} \approx 0.2887; σs\sigma_s is infinite because s2sinc⁡2(s)s^2 \operatorname{sinc}^2(s) does not decay.

Solution
python · try it yourself
import numpy as np
t = np.linspace(-0.5, 0.5, 100001)
print(round(float(np.sqrt(np.mean(t ** 2))), 4), round(1 / np.sqrt(12), 4))
0.2887 0.2887

s2sinc⁡2(s)=sin⁡2(πs)/π2s^2 \operatorname{sinc}^2(s) = \sin^2(\pi s)/\pi^2 oscillates without decaying, so its integral diverges. The inequality holds trivially, but σs\sigma_s is a poor measure of bandwidth for signals with jumps.

Test yourself

The uncertainty principle bounds…

  1. σt+σs\sigma_t + \sigma_s
  2. σtσs≥1/(4π)\sigma_t \sigma_s \ge 1/(4\pi)
  3. σt/σs\sigma_t / \sigma_s
  4. the energy

Which signals achieve equality?

  1. rectangles
  2. sinc functions
  3. Gaussians
  4. exponentials

To resolve two tones 1 Hz apart you need about…

  1. 1 ms of signal
  2. 1 s of signal
  3. 1 sample
  4. 1 minute