A robot vibration report uses several short windows to estimate the power near a recurring frequency. One window contains a much larger oscillation. The mean spectrum reflects that additional power, while the median spectrum can remain close to its normal reading. Comparing both estimates helps the reviewer decide which part of the original recording needs a closer look.
Change one segment and keep the analysis fixed
Welch's method divides a trace into segments, computes a spectrum for each segment, and combines the spectra. This fixture contains five one-second segments from a synthetic accelerometer sampled at 128 Hz. Each contains an 8 Hz sine wave. The third segment is multiplied by eight in the modified trace. A rectangular window, no overlap, and an integer number of cycles make the comparison easy to reproduce.
import numpy as np
from scipy.signal import welch
t = np.arange(128) / 128
clean = np.tile(np.sin(2 * np.pi * 8 * t), 5)
modified = clean.copy()
modified[256:384] *= 8
settings = dict(fs=128, nperseg=128, noverlap=0, window="boxcar")
f, mean = welch(modified, average="mean", **settings)
_, median = welch(modified, average="median", **settings)
_, clean_median = welch(clean, average="median", **settings)
peak = np.flatnonzero(f == 8)[0]
assert np.isclose(mean[peak], 6.8)
assert np.isclose(median[peak], 0.638298)
assert np.isclose(median[peak], clean_median[peak])
SciPy 1.18.1 and NumPy 2.5.5 produced these results. The units of the density are squared input units per hertz. Only one of the five segment spectra has the larger 8 Hz value, so the median in each frequency bin still comes from a typical segment in this example. SciPy's median estimate includes a bias correction. Its value here is about 0.6383, while the ordinary mean for the all-clean trace is 0.5 at the same bin.
Preserve transient evidence alongside the summary
Keep the averaging method, window, segment length, overlap, sample rate, and scaling in the report. Those settings can change which samples contribute to each segment and how power is distributed across bins. A strong event can affect several overlapped windows, and a change in operating regime can affect most of the record. The comparison in this fixture does not establish how either estimator behaves in those cases.
For a report that must account for a brief event, keep the raw trace and the time interval of the event. Review the spectrum of the affected segment with the same frequency settings so a reader can trace a difference between the two summaries back to the recorded signal.
Sources
SciPy Welch reference for segment processing, scaling, and mean or median averaging
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.welch.html
SciPy periodogram reference for individual spectral estimates and density units
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.periodogram.html