Qu

periodogram

Builtin index · Signal processing

result = periodogram(x, fs, [window="hann"])

Input: x, fs, window · Output: result

What it is

x: a length-N real vector; fs (number, Hz); window (optional string).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = periodogram(x, fs, [window="hann"])
x vectorx: a length-N real vector.
fs numberfs (number, Hz).
window string, optional (default "hann")window (optional string).
welch vectorchanged in v0.2.4 from a bare vector, back-compatibly — see welch
Returns a spectrum of N/2 + 1 one-sided bins stamped norm = "density", same scaling as welch (changed in v0.2.4 from a bare vector, back-compatibly — see welch). The simplest PSD estimate — welch's one-segment (nperseg=length(x), noverlap=0), no-averaging special case.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

fs = 1000
n = 0:1:1023
t = n / fs
x = sin(2*pi*100*t) + 0.05 * randn(1024, seed=1)

psd_w = welch(x, fs, nperseg=256)
f_w = linspace(0, fs/2, length(psd_w))
peak_w = find_peaks(psd_w, min_height=max(psd_w)*0.5)
print("welch peak near {f_w[peak_w[0]]} Hz")

psd_p = periodogram(x, fs)          # single-segment special case of welch

f_p = linspace(0, fs/2, length(psd_p))
peak_p = find_peaks(psd_p, min_height=max(psd_p)*0.5)
print("periodogram peak near {f_p[peak_p[0]]} Hz")
output
welch peak near 101.5625 Hz
periodogram peak near 99.609375 Hz

from signal-processing

How it works

periodogram(x, fs, [window="hann"]) — the simplest PSD estimate: one segment (the whole signal), one window, no averaging — welch's nperseg = length(x), noverlap = 0 special case, scaled identically (see welch's own comment for the exact "density" scaling and Parseval-integration check).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.