Skip to content

Power spectral density

See how a random signal's power spreads over frequency: the DTFT of its autocorrelation, reshaped by a filter's gain squared into pink or brown noise.

Before this15.4 · 24.2 · 4 more
Chapter 24 · Lesson 4 of 4

First, the picture

A random signal keeps its power somewhere along the frequency axis. Here AR(1) noise, whose samples remember a share aa of their neighbour, is drawn twice: its autocorrelation, and its power at each frequency. Watch both as aa grows from 0: the longer the memory, the narrower the spectrum.

Memory in time, narrowness in frequency

AR(1) noise of variance 1: R_x[ℓ] = a^{|ℓ|} and its DTFT, the PSD.

a = 0, white noise: R_x is a single stem at lag 0, and the PSD is flat at 0.0 dB.

a
0.00
S_x at Ω = 0
0.0 dB
S_x at Ω = π
0.0 dB
0.00 / 13.00 s
Describe this picture

Two panels for AR(1) noise of variance 1. The first shows the autocorrelation Rx[ℓ]=a∣ℓ∣R_x[\ell]=a^{\lvert\ell\rvert} as stems, from −1 to 1.1 against lag ℓ from −20 to 20. The second shows its DTFT, the PSD, as a solid curve in dB from −20 to 20 against Ω from 0 to π rad/sample. A dotted level at 0 dB, labelled “white”, marks the flat PSD of variance-1 white noise. The readouts are aa and the PSD at Ω = 0 and at Ω = π, in dB. At a=0a=0, white noise, RxR_x is a single stem at lag 0 and the PSD is flat at 0.0 dB. As aa grows the autocorrelation spreads and the PSD gathers at low frequencies. At a=0.5a=0.5, RxR_x halves at each step, and the PSD is 4.8 dB at 0 and −4.8 dB at π. At a=0.9a=0.9, a long memory and a narrow spectrum, it is 12.8 dB at 0 and −12.8 dB at π, and the caption ends: “The area under the PSD, the power, is still 1.” After the clip a slider “a” runs from −0.95 to 0.95 in steps of 0.05; at −0.5 the caption reads “a = −0.50: −4.8 dB at 0, 4.8 dB at π: memory that alternates in sign moves the power up.”

Power per frequency

In Random processes (24.2), “White noise forgets, coloured noise remembers” measured how alike two samples ℓ\ell apart are. That was the autocorrelation, Rx[ℓ]=E{x[n] x[n−ℓ]}R_x[\ell]=\mathbb{E}\{x[n]\,x[n-\ell]\}. White noise had none beyond lag 0, and AR(1) noise kept a share aa of its likeness per step. On this page I ask the same question in frequency: where along the frequency axis does a random signal keep its power?

Let’s start with a signal whose answer we know: a sine. In “A test sine goes in, a scaled and shifted sine comes out” of Frequency response of discrete-time systems (12.4), a sine of amplitude AA came out of a system ∣H(ejΩ)∣\lvert H(e^{j\Omega})\rvert times as big. Its average power, from How big is a signal (1.3), was A2/2A^2/2 going in. Coming out it is ∣H∣2A2/2\lvert H\rvert^2A^2/2. So a system multiplies the power at each frequency by ∣H∣2\lvert H\rvert^2.

A noise has no single frequency. Its power is spread over the band, as the quantizer’s error was in “Sharing the same error among more slices” of Oversampling and noise shaping (11.3). There I said that this error’s power sits evenly from 0 to fs/2f_s/2, and promised the proof for this page.

To describe a spread I need a density: the power per unit of frequency near Ω\Omega. That is the power spectral density, or PSD, written Sx(ejΩ)S_x(e^{j\Omega}). Adding it up over the whole band gives the whole power. For a process of mean 0, like every one on this page, that power is Rx[0]R_x[0], the average power PP of 1.3:

Rx[0]=12π∫−ππSx(ejΩ) dΩ.R_x[0]=\frac1{2\pi}\int_{-\pi}^{\pi}S_x(e^{j\Omega})\,d\Omega .

Now filter the noise. Each narrow slice of frequency goes through like a test sine, so its power is multiplied by ∣H∣2\lvert H\rvert^2. The output’s PSD is

Sy(ejΩ)=∣H(ejΩ)∣2 Sx(ejΩ).S_y(e^{j\Omega})=\lvert H(e^{j\Omega})\rvert^2\,S_x(e^{j\Omega}).

This needs a stable system and an input that has been running for a long time, 12.4’s steady state. The angle ∠H\angle H does not appear: delaying a noise does not move its power to other frequencies.

Wiener–Khinchin: the PSD is the DTFT of the autocorrelation

Where does SxS_x come from? Take NN samples of the process and their DFT X[k]X[k]. In “Energy in time and in bins” of The DFT (13.2), the energy of the samples was 1N∑k∣X[k]∣2\frac1N\sum_k\lvert X[k]\rvert^2. Divide by NN once more and you have the power, the average over the NN bins of ∣X[k]∣2/N\lvert X[k]\rvert^2/N. So ∣X[k]∣2/N\lvert X[k]\rvert^2/N is the power that sits at bin kk.

What is that number on average? Write it at any Ω\Omega, with XN(ejΩ)=∑n=0N−1x[n]e−jΩnX_N(e^{j\Omega})=\sum_{n=0}^{N-1}x[n]e^{-j\Omega n}, the DTFT of the NN samples. Multiply out the square and take the expected value of “Mean and variance” in Random variables for signals (24.1). Each product x[n] x[m]x[n]\,x[m] becomes Rx[n−m]R_x[n-m], and the N−∣ℓ∣N-\lvert\ell\rvert pairs with the same lag ℓ=n−m\ell=n-m give the same term:

1N E{∣XN∣2}=1N∑n=0N−1∑m=0N−1Rx[n−m]×e−jΩ(n−m)=∑ℓ=−(N−1)N−1(1−∣ℓ∣N)×Rx[ℓ] e−jΩℓ.\begin{aligned} \frac1N\,\mathbb{E}\{\lvert X_N\rvert^2\} &=\frac1N\sum_{n=0}^{N-1}\sum_{m=0}^{N-1}R_x[n-m]\\ &\qquad\times e^{-j\Omega(n-m)}\\ &=\sum_{\ell=-(N-1)}^{N-1}\Big(1-\frac{\lvert\ell\rvert}N\Big)\\ &\qquad\times R_x[\ell]\,e^{-j\Omega\ell}. \end{aligned}

As NN grows the weights 1−∣ℓ∣/N1-\lvert\ell\rvert/N tend to 1, and what is left is the DTFT of the autocorrelation, from The DTFT (12.2):

Sx(ejΩ)=∑ℓRx[ℓ] e−jΩℓ.S_x(e^{j\Omega})=\sum_\ell R_x[\ell]\,e^{-j\Omega\ell}.

This is the Wiener–Khinchin theorem. Read backwards, the inverse DTFT gives Rx[ℓ]R_x[\ell] from SxS_x, and at ℓ=0\ell=0 it is the power formula above. An autocorrelation is even, Rx[−ℓ]=Rx[ℓ]R_x[-\ell]=R_x[\ell], so the sum is Rx[0]+2∑ℓ≥1Rx[ℓ]cos⁡(Ωℓ)R_x[0]+2\sum_{\ell\ge1}R_x[\ell]\cos(\Omega\ell): a real curve, and an even one.

White noise v[n]v[n] of variance σv2\sigma_v^2 has Rv[ℓ]=σv2 δ[ℓ]R_v[\ell]=\sigma_v^2\,\delta[\ell]. Only the ℓ=0\ell=0 term survives, so

Sv(ejΩ)=σv2at every Ω.S_v(e^{j\Omega})=\sigma_v^2\quad\text{at every }\Omega .

The PSD is flat: equal power at every frequency. That is the promise of 11.3 kept, for an error that behaves like white noise.

The AR(1) pair

Now the coloured noise of 24.2, AR(1) scaled to variance 1, x[n]=a x[n−1]+1−a2 v[n]x[n]=a\,x[n-1]+\sqrt{1-a^2}\,v[n] with σv2=1\sigma_v^2=1. Its autocorrelation is Rx[ℓ]=a∣ℓ∣R_x[\ell]=a^{\lvert\ell\rvert}.

Split the sum at ℓ=0\ell=0. The lags ℓ≥0\ell\ge0 give the geometric series of “One arrow, two curves” in 12.2, the DTFT of anu[n]a^nu[n], which settles because ∣a∣\lvert a\rvert is less than 1. The negative lags give the same series in e+jΩe^{+j\Omega}, starting one step later:

Sx=∑ℓ=0∞(ae−jΩ)ℓ+∑m=1∞(aejΩ)m=11−ae−jΩ+aejΩ1−aejΩ.\begin{aligned} S_x&=\sum_{\ell=0}^{\infty}\left(ae^{-j\Omega}\right)^\ell+\sum_{m=1}^{\infty}\left(ae^{j\Omega}\right)^m\\ &=\frac1{1-ae^{-j\Omega}}+\frac{ae^{j\Omega}}{1-ae^{j\Omega}} . \end{aligned}

Put both over the common denominator (1−ae−jΩ)(1−aejΩ)=1−2acos⁡Ω+a2(1-ae^{-j\Omega})(1-ae^{j\Omega})=1-2a\cos\Omega+a^2. The numerator is 1−aejΩ+aejΩ−a2=1−a21-ae^{j\Omega}+ae^{j\Omega}-a^2=1-a^2, so

Sx(ejΩ)=1−a21−2acos⁡Ω+a2.S_x(e^{j\Omega})=\frac{1-a^2}{1-2a\cos\Omega+a^2}.

There is a second road to the same answer. AR(1) noise is white noise of variance 1−a21-a^2 sent through the recursion 1/(1−ae−jΩ)1/(1-ae^{-j\Omega}), so Sy=∣H∣2SxS_y=\lvert H\rvert^2S_x gives (1−a2)/∣1−ae−jΩ∣2(1-a^2)/\lvert1-ae^{-j\Omega}\rvert^2, the same curve. At Ω=0\Omega=0 the formula is (1+a)/(1−a)(1+a)/(1-a), and at Ω=π\Omega=\pi it is (1−a)/(1+a)(1-a)/(1+a).

Memory in time, narrowness in frequency

The picture at the top of the page draws Rx[ℓ]R_x[\ell] and its DTFT together for AR(1) noise, as aa grows from 0. Its decibels are 10log⁡10Sx10\log_{10}S_x, as for any power in “Signal and noise, in decibels” (1.3). Think of a crowd: a crowd that sways slowly hums low, and a jittery one hisses.

Notice the end caption’s last sentence. The power is the same, 1, at every aa: it only moves in frequency. The area is that of SxS_x itself; in dB the curve is mirrored about 0 dB, because Sx(ej0) Sx(ejπ)=1S_x(e^{j0})\,S_x(e^{j\pi})=1.

Where does the curve cross the white level? Sx=1S_x=1 when 1−a2=1−2acos⁡Ω+a21-a^2=1-2a\cos\Omega+a^2, that is, when cos⁡Ω=a\cos\Omega=a. For a=0.5a=0.5 that is Ω=π/3\Omega=\pi/3, and for a=0.9a=0.9 it is 0.144π0.144\pi. Below that frequency the power is raised, and above it the power is cut.

How narrow is narrow? At a=0.9a=0.9, the slowest tenth of the band, ∣Ω∣\lvert\Omega\rvert below 0.1π0.1\pi, holds 79.6 % of the power; white noise keeps 10 % there.

The PSD falls to half its peak at Ω=0.105\Omega=0.105 rad/sample. The autocorrelation falls to 1/e1/e of its first value after −1/ln⁡0.9=9.49-1/\ln0.9=9.49 lags. Their product, 9.49×0.1059.49\times0.105, is 1.00: the longer the memory, the narrower the spectrum.

After the clip, use the slider to try a negative aa. At −0.5-0.5 the PSD is −4.8 dB at 0 and 4.8 dB at π: memory that alternates in sign moves the power up. Neighbours now tend to have opposite signs, so the power gathers near π\pi. At either end of the slider the PSD reaches ±15.9 dB, still inside the panel.

Does a recording agree with the formula? I drew 400 realisations of 256 samples each, with a=0.9a=0.9, from the site’s seeded generator (seed 244). For each I took ∣X[k]∣2/256\lvert X[k]\rvert^2/256 and then averaged the 400 results, bin by bin. At every bin from 1 to 127 the average is within 0.61 dB of SxS_x.

At Ω=0\Omega=0 the average reads 0.900 of SxS_x. The peak there is so sharp that 256 samples blur it: the weights 1−∣ℓ∣/N1-\lvert\ell\rvert/N above predict 0.963. The rest is the scatter of 400 random results, about 5 % for one bin. Estimating a PSD from data is the subject of The periodogram (25.1).

Equal power in every octave

Our ears judge pitch by ratios. From 20 Hz to 40 Hz is one octave, a doubling, as in 11.3, and so is 10 kHz to 20 kHz. The range we hear, 20 Hz to 20 kHz, is just under 10 octaves.

White noise has the same power in every hertz. Its octave from 10 to 20 kHz is 10 000 Hz wide, and its octave from 20 to 40 Hz only 20 Hz wide. So the top octave holds 500 times the power, 27.0 dB more, and white noise sounds like a hiss.

Pink noise has the same power in every octave instead: 20 to 40 Hz holds as much as 10 to 20 kHz. Each octave is twice as wide as the one before it, so to hold the same power its PSD must be half as high. Half the power is 10log⁡1012=−3.0110\log_{10}\tfrac12=-3.01 dB, so pink noise falls 3.01 dB per octave.

Brown noise is white noise added up, a random walk: s[n]=s[n−1]+v[n]s[n]=s[n-1]+v[n]. The first difference of 11.3, 1−e−jΩ1-e^{-j\Omega}, has gain 2∣sin⁡(Ω/2)∣2\lvert\sin(\Omega/2)\rvert, as 12.4 worked out, and adding up undoes a first difference. So the running sum has gain 1/(2∣sin⁡(Ω/2)∣)1/(2\lvert\sin(\Omega/2)\rvert), and

Ss(ejΩ)=σv24sin⁡2(Ω/2).S_s(e^{j\Omega})=\frac{\sigma_v^2}{4\sin^2(\Omega/2)} .

For small Ω\Omega, sin⁡(Ω/2)\sin(\Omega/2) is close to Ω/2\Omega/2, so SsS_s is close to σv2/Ω2\sigma_v^2/\Omega^2. Each doubling of frequency then divides the power by 4: 10log⁡1014=−6.0210\log_{10}\tfrac14=-6.02 dB per octave.

A pure random walk wanders off: its variance grows with nn, so it is not stationary, and its PSD is infinite at Ω=0\Omega=0.

In practice I let the sum leak a little, s[n]=0.995 s[n−1]+v[n]s[n]=0.995\,s[n-1]+v[n], the leaky integrator of Difference equations (6.1) with a different constant. That is AR(1) noise with a=0.995a=0.995, a longer memory than the first instrument reaches. Its PSD is flat below a corner of about (1−0.995)(1-0.995) rad/sample and falls about 6 dB per octave above it. At fs=44.1f_s=44.1 kHz the corner is 0.005⋅44 100/2π=35.10.005\cdot44\,100/2\pi=35.1 Hz.

No simple recursion falls exactly 3 dB per octave. J. O. Smith’s pink-noise filter comes close with three poles and three zeros. They take turns along the real axis between 0.1 and 1. The falls of the poles and the rises of the zeros overlap, and on average the slope is near −3 dB per octave.

White, pink, brown

The second instrument passes white noise at 44.1 kHz through the two filters and draws the three PSDs. The frequency axis is logarithmic: each octave takes the same width, so a fixed number of dB per octave is a straight line. Rain on leaves sounds pink, a distant waterfall brown, and radio static white.

White, pink, brown

White noise at 44.1 kHz through two filters; PSD in dB re its value at 1 kHz.

White noise: the same power at every frequency, a flat line.

colour
white
slope, 200 to 3200 Hz
0.00 dB
Colour
0.00 / 12.00 s
Describe this picture

One panel: white noise at 44.1 kHz through two filters, with each PSD in dB re its value at 1 kHz, from −30 to 30, against frequency from 20 Hz to 20 kHz on a log scale. The curve “white” is dotted, “pink” solid and “brown” dashed, each labelled at its high-frequency end. Two thin dotted guide lines pass through 1 kHz, one falling 3.01 dB per octave and one 6.02. The readouts are the colour and its slope from 200 to 3200 Hz, in dB per octave. A button, “Hear it”, plays 2 s of the chosen colour. The clip adds one curve at a time. White noise has the same power at every frequency, a flat line at 0.00 dB per octave. Pink falls −2.94 dB per octave, equal power in every octave, and keeps within 0.67 dB of the exact −3.01 dB line from 20 Hz to 20 kHz. Brown is white noise through a leaky integrator, about −6 dB per octave (−5.97) above its corner at 35.2 Hz, and the caption ends: “S_y = |H|² S_x: the filter’s gain squared is the colour.” After the clip three buttons, “white”, “pink” and “brown”, in a group named “Colour”, choose the curve drawn at full strength; the other two are drawn faintly.

Notice that pink measures −2.94 dB per octave, not exactly −3.01. The filter only approximates the ideal slope, but over the band we hear it never strays from it by more than 0.67 dB.

Brown’s slope eases near the top, to −5.46 dB from 5 to 10 kHz and −3.60 dB from 10 to 20 kHz. ∣H∣\lvert H\rvert is even and repeats every 2π2\pi, so it is mirrored about Ω=π\Omega=\pi, which is 22.05 kHz here, and every curve levels off as it nears that frequency.

After the clip, choose each colour and press “Hear it”: white hisses, pink sounds even, and brown rumbles.

Every colour here came from the same white noise. Only ∣H∣2\lvert H\rvert^2 differed, and Sy=∣H∣2SxS_y=\lvert H\rvert^2S_x turned it into the colour. To make noise of a given shape, design a filter whose gain squared has that shape, as closely as a filter can, and feed it white noise.

The maths behind it · eigenvalues of Toeplitz matrices

In “Arrows in, the same arrows out” of The DFT as a matrix (13.5), the DFT’s arrows were the eigenvectors of every circulant matrix. The autocorrelations of 24.2 fill a Toeplitz matrix, entry Rx[p−q]R_x[p-q]. For long records it is nearly circulant, so its eigenvalues approach samples of the PSD (Szegő’s theorem). The PSD is the spectrum of the correlation matrix in both senses.

Worked example

1. AR(1) PSD. For a=0.5a=0.5, SxS_x at Ω=0\Omega=0 is 1.5/0.5=3.001.5/0.5=3.00, which is 4.77 dB, and at π\pi it is 0.5/1.5=0.33330.5/1.5=0.3333, which is −4.77-4.77 dB. For a=0.9a=0.9 the two values are 1.9/0.1=19.001.9/0.1=19.00 and 0.1/1.9=0.05260.1/1.9=0.0526, or 12.79 dB and −12.79-12.79 dB.

2. Through a filter. 12.2’s signal 0.8nu[n]0.8^nu[n] had ∣X∣=5\lvert X\rvert=5 at Ω=0\Omega=0 and 0.556 at π\pi. Used as a filter on white noise of variance 1−0.82=0.361-0.8^2=0.36, it gives Sy=25×0.36=9S_y=25\times0.36=9 at 0 and 0.36/1.82=0.1110.36/1.8^2=0.111 at π\pi. The AR(1) formula with a=0.8a=0.8 gives the same, 1.8/0.2=91.8/0.2=9 and 0.2/1.8=0.1110.2/1.8=0.111, or 9.54 dB and −9.54-9.54 dB.

3. Octaves. Pink noise falls 10log⁡102=3.0110\log_{10}2=3.01 dB per octave and brown noise 20log⁡102=6.0220\log_{10}2=6.02 dB. Over the log⁡21000=9.97\log_2 1000=9.97 octaves from 20 Hz to 20 kHz, pink falls 30.0 dB, which is 10log⁡10100010\log_{10}1000, and brown falls 60.0 dB.

4. Units. The band from −π-\pi to π\pi is fsf_s hertz wide, so in hertz the two-sided density is Sx(f)=Sx(ejΩ)/fsS_x(f)=S_x(e^{j\Omega})/f_s, with Ω=2πf/fs\Omega=2\pi f/f_s. For white noise of variance 1 V² at fs=8f_s=8 kHz that is 1.25×10−41.25\times10^{-4} V²/Hz. The one-sided density of “One spectrum, four units” in Reading a spectrum: scaling and units (15.4) doubles it, to 2.5×10−42.5\times10^{-4} V²/Hz, or −36.0-36.0 dB re 1 V²/Hz.

Where you’ll meet this

Sound engineers play pink noise through loudspeakers and read the room with an analyser whose bands are an octave or a third of an octave wide. Pink noise puts equal power in every such band, so a flat reading means a flat system.

Random walks model slow drift: a gyroscope’s bias, a clock’s error, the position of an object pushed by random forces. The Kalman filter of RLS and the Kalman filter (26.4) builds such coloured noise into its model. Noise shaping, in “What a first difference does to slow and fast wiggles” of 11.3, is a designed ∣H∣2\lvert H\rvert^2. The quantizer’s white error goes through 1−e−jΩ1-e^{-j\Omega}, and its PSD becomes 4sin⁡2(Ω/2)4\sin^2(\Omega/2) times the flat one.

Estimating a PSD from a recording comes next, in The periodogram (25.1) and Averaged periodograms: Bartlett and Welch (25.2). Parametric models and linear prediction (25.3) fits AR models and reads their PSD from the formula. The Wiener filter (26.2) builds a filter from the PSDs of a signal and of its noise.

The maths behind it · ARMA spectra

In statistics, the spectral density of a stationary time series is this PSD. An ARMA model’s spectrum is the white noise’s variance times ∣B/A∣2\lvert B/A\rvert^2, the same Sy=∣H∣2SxS_y=\lvert H\rvert^2S_x rule. That track writes a random variable as a capital XX and the variance as σ2\sigma^2, where this page writes x[n]x[n] and σv2\sigma_v^2.

Reference card

QuantityFormulaNotes
Wiener–KhinchinSx(ejΩ)=∑ℓRx[ℓ]e−jΩℓS_x(e^{j\Omega})=\sum_\ell R_x[\ell]e^{-j\Omega\ell}the DTFT of the autocorrelation
PowerRx[0]=12π∫−ππSx dΩR_x[0]=\frac1{2\pi}\int_{-\pi}^{\pi}S_x\,d\Omegamean 0
WhiteSv=σv2S_v=\sigma_v^2flat
AR(1), variance 1Sx=1−a21−2acos⁡Ω+a2S_x=\dfrac{1-a^2}{1-2a\cos\Omega+a^2}1+a1−a\frac{1+a}{1-a} at 0, 1−a1+a\frac{1-a}{1+a} at π\pi
Through a filterSy=∣H∣2SxS_y=\lvert H\rvert^2S_xcolour = gain squared
Pink−3.01 dB per octaveequal power per octave
Brown−6.02 dB per octavea random walk; leaky in practice
In hertzSx(f)=Sx(ejΩ)/fsS_x(f)=S_x(e^{j\Omega})/f_stwo-sided; one-sided doubles

End of lesson 24.4

Where to go next.

Phasorium
LibraryEvery lesson, in order

Parts

About Phasorium
Look