# Spectral density
The **spectral density** of a signal describes how its power, or its energy, is distributed across frequency: a single value at each frequency, or band of frequencies, saying how much of the signal lives there. For a signal whose total energy is finite, the relevant quantity is the energy spectral density; for a signal that runs on indefinitely, such as a steady tone or a hiss of noise, it is the power spectral density, the go-to description of noise and random signals throughout engineering and physics. The primary microsim on this page builds exactly such a signal, a tone buried in adjustable noise, and lets the reader estimate its power spectral density two different ways, watching a raw, spiky estimate settle into a smooth curve as more data is averaged in.
The two spectral densities share the same units logic, power or energy per unit frequency, so that integrating the curve across all frequency returns the signal's total power or energy exactly, a form of Parseval's theorem the sketch checks live rather than assumes. Because the defining relationship needs an infinite record to hold exactly, every practical estimate is instead built from a finite one, and the trade-off between how sharply that estimate resolves nearby frequencies and how much its own noise averages out is the central, recurring lesson of spectral estimation.
The same quantity separates white noise's flat spectrum from the sloped spectra of pink and Brownian noise, sets the noise floor beneath every radio and audio signal, and, at cosmological scale, encodes the geometry of the early universe in the pattern of the cosmic microwave background.
## Units
Because energy and power spectral density describe different kinds of signal, the two carry different units. A finite-[[Energy|energy]] signal's energy spectral density is energy per unit frequency — for a [[Voltage|voltage]] waveform, typically volt-squared-seconds per hertz, which is the same thing as volt-squared per hertz-squared multiplied by hertz, since a second and an inverse hertz are the same unit. A signal that runs on indefinitely instead has a power spectral density, power per unit frequency, most often quoted in watts per hertz for a physical power or volts-squared per hertz for a voltage that has not yet been divided by a load resistance. The distinction tracks a simple rate: power is energy divided by time, so a power spectral density can be read as an energy spectral density spread over an ever-growing observation window.
A further choice, independent of the physical units, is whether the frequency axis runs over all real frequencies, positive and negative, or only over the non-negative half. The two-sided density is the natural output of the [[Fourier_transform]] and is symmetric for a real signal; the one-sided density instead folds the negative-frequency half onto the positive one, doubling its values so the same total power is recovered by integrating over positive frequencies alone. Instruments and datasheets almost always report the one-sided form, and the sketch on this page plots [[Decibel|decibels]] on exactly that one-sided, positive-frequency axis.
## Definition
For a signal `x(t)` with finite total energy, Parseval's theorem states that the energy computed in the time domain, `integral |x(t)|^2 dt`, equals the energy computed in frequency, `integral |X(f)|^2 df`, where `X(f)` is the signal's Fourier transform. The integrand on the frequency side, `|X(f)|^2`, is the energy spectral density: it shows how the signal's fixed, finite store of energy is distributed across frequency, and integrating any slice of it gives exactly the energy carried in that band.
Most signals of practical interest, however, do not have finite energy at all — a steady carrier, a running noise process — because they are treated as persisting for all time. For these the relevant quantity is the power spectral density, defined either as a limit of the energy spectral density per unit time as the observation window grows without bound, or, for a random process, as the Fourier transform of the [[Autocorrelation]] function, `S_xx(f) = integral R_xx(τ) e^{-j2πfτ} dτ`, a result usually called the Wiener–Khinchin theorem.[^wk-name] The two definitions agree wherever both apply, and both share the same defining property: the power spectral density is always real and non-negative, and, for a real-valued signal, an even function of frequency, since a real autocorrelation always has a real, even Fourier transform.
A cross power spectral density extends the idea to a pair of signals, `S_xy(f)`, built from their cross-correlation rather than either one's own autocorrelation. Unlike an ordinary spectral density it is generally complex, and its phase carries the frequency-dependent delay between the two signals, which is what makes it the tool of choice for identifying a [[Transfer_function|transfer function]] or an [[Impulse_response|impulse response]] from measured input and output records rather than from a circuit diagram alone. The physical picture in every case is the one Parseval's theorem states for the energy version: the area under a power spectral density curve, `integral S_xx(f) df`, equals the signal's total average power, or equivalently its variance if the signal has zero mean, the identity the sketch on this page checks numerically every time a control changes.
## Estimation
The Wiener–Khinchin definition is exact only for an infinite record, so every practical estimate works from a finite one instead. The most direct estimate, the periodogram, simply takes the discrete Fourier transform of an N-sample record and scales the squared magnitude of each bin, `Ŝ(f_k) = |X_k|^2 / (N·fs)`, the same formula this page's sketch computes. The periodogram is unbiased on average, but it is not consistent: taking a longer record does not shrink its variance, so a raw periodogram of a noisy signal looks like grass no matter how much data feeds it, a fact the sketch demonstrates directly when its averaging is switched off.
Welch's method is the standard cure.[^welch-orig] The record is split into shorter, overlapping segments, each one is multiplied by a window function to control [[Spectral_leakage|spectral leakage]] at its edges, a periodogram is computed for each segment, and the results are averaged. Averaging K segments divides the estimate's variance by roughly K, at the cost of coarsening the frequency resolution to `Δf = fs / L`, where L is the shortened segment length: a direct trade of resolution for a smoother curve, and the one the sketch's segment-count control lets the reader make for themselves. A [[Window_function|window]] shaped to taper smoothly to zero at each segment's edges, rather than cut it off sharply, further reduces the leakage that a plain rectangular window would otherwise smear across nearby frequencies, at some cost to the sharpness of the tone itself.
## Related concepts
The Wiener–Khinchin link between a power spectral density and an autocorrelation function is one instance of a broader pattern: many second-order statistical descriptions of a signal turn out to be Fourier pairs of one another, so a fact that is awkward to see in one domain is often obvious in the other. The normalized cross power spectral density, called coherence, plays the same role between two signals that ordinary correlation plays between two numbers, reading 1 at a frequency where one signal is an exact linear copy of the other and falling toward 0 where the two are unrelated there. The same construction is not limited to time signals at all: replacing time with position turns a power spectral density into a spatial-frequency description used to characterize surface roughness, turbulence, and the large-scale structure of matter in the universe, on exactly the same mathematics used for a signal in time. A [[Short-time_Fourier_transform|short-time Fourier transform]], which slides a window along the signal and takes a spectral density of each windowed piece, extends the idea further, to a signal whose spectral content itself changes over time, at the cost of the same resolution trade-off Welch's method already makes within a single window.
## Applications
In electrical engineering, the power spectral density is the language of noise. Thermal agitation in any [[Resistor]] produces [[Noise_(electronics)|Johnson–Nyquist noise]] with a flat spectral density up to very high frequencies, the paradigm case of white noise; integrating a white spectrum against time, as a random walk does, produces Brownian, or "red," noise whose spectral density instead falls as `1/f^2`, and a family of intermediate slopes, `P(f) = K/f^β`, spans white noise at β = 0 through pink noise for 0 < β < 2 to Brownian noise at β = 2.[^colors] The slope is not a curiosity: pink noise, close to β = 1, turns up in circuit flicker noise, in audio and acoustics, and in traffic and financial data, and the serial correlation between neighboring samples climbs steadily with β, from a small fraction of a percent for white noise to nearly perfect correlation for Brownian noise.[^serial-corr] The same spectral language sets the noise floor beneath a radio receiver, the hiss a [[Signal-to-noise_ratio|signal-to-noise ratio]] is measured against, and it is what a [[Wiener_filter|Wiener filter]] uses to separate a signal from noise whose spectral density it already knows.
In cosmology the same tool is turned on the sky itself. The tiny temperature differences across the cosmic microwave background are decomposed into a power spectrum over angular scale rather than over time, and the pattern of peaks in that spectrum, acoustic oscillations frozen into the early universe's hot plasma, encodes the universe's composition, curvature and age with a precision no single image of the sky could match on its own.[^cmb]
## Microsims
This article carries one sketch, built around the periodogram and Welch's method described above.
**Power spectral density** builds a test signal from a strong tone plus adjustable white noise, estimates its spectral density both ways, and checks the result against a diagnostics readout comparing the area under the curve to the signal's own measured variance. A NOISE control sets the standard deviation of the added noise, a STRONG TONE control sets the tone's frequency, a WELCH K control steps through a small set of segment counts, and buttons toggle the analysis window between rectangular and Hann and toggle a reference line showing the true noise floor.
*Try:* Raise NOISE until the floor climbs high enough to swallow the tone, then raise WELCH K and watch the same buried tone settle back out of the grass.
A three.js companion renders the same colours-of-noise idea in depth: a signal's waveform and log-log spectral slope as its power-law exponent β sweeps from white through pink to Brownian.
## Wikipedia : Wikitube
**Strict pair:** [Wikipedia](https://en.wikipedia.org/wiki/Spectral_density) : [Wikitube](https://en.wikitube.io/wiki/Spectral_density)
Skeleton mirrored at revision 1371627674. Prose, emphasis and the microsims are Wikitube's own.
## See also
- [[Autocorrelation]]
- [[Fourier_transform]]
- [[Spectral_leakage]]
- [[Noise_(electronics)]]
- [[Wiener_filter]]
- [[Signal-to-noise_ratio]]
- [[Short-time_Fourier_transform]]
- [[Window_function]]
## Notes
Page numbers in the references below are PDF pages of the open textbook edition cited, not necessarily the printed page numbers of any other edition of the same book.
## References
[^wk-name]: Citation needed: a primary citation for the Wiener–Khinchin theorem (Norbert Wiener's and Aleksandr Khinchin's original papers relating a power spectral density to an autocorrelation function).
[^welch-orig]: Citation needed: a primary citation (author, title, venue, year) for P. D. Welch's method of averaged, overlapped, windowed periodograms.
[^colors]: Downey, A. *Think DSP: Digital Signal Processing in Python*. 2012, p. 56 (PDF page): the power-law spectrum `P = K/f^β`, with white noise at β = 0, pink noise for 0 < β < 2, and Brownian (red) noise at β = 2. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/think-dsp-digital-signal-processing-in-python . CC BY-NC.
[^serial-corr]: Downey, A. *Think DSP: Digital Signal Processing in Python*. 2012, p. 66 (PDF page): serial correlation of about 0.006 for uncorrelated uniform noise, 0.851 for pink noise at β = 1, and above 0.999 for Brownian noise. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/think-dsp-digital-signal-processing-in-python . CC BY-NC.
[^cmb]: Citation needed: a primary citation (mission, paper or agency report) for the cosmic microwave background angular power spectrum and its acoustic-peak measurements.
## External links
- Power spectral density: live sketch https://editor.p5js.org/sciencenibber/full/BEdJbe1T8 · editor https://editor.p5js.org/sciencenibber/sketches/BEdJbe1T8
<!-- Hubs: Signal_processing. Portals: PORTAL_Signal_Processing. Signal Processing portal wave 1 · 2026-09-17 · drafted. -->