← Lab
detrendwin
confirmedupstream bugPython · spectrumSystems & data structuresJuly 25, 2026
the question
Does spectrum's speriodogram remove the mean before applying the window?
what came out
spectrum's speriodogram computes |rfft(x*w - m)|^2, subtracting the mean after windowing instead of (x - m)*w. A constant input that should detrend to zero keeps full power (1704 for 5*ones(256)) with a window-shaped DC spike. The fix is to detrend before windowing.
method & receipts
- Result: confirmed
- Reproducible — one script re-runs the whole thing from scratch.
- Tested — a correctness/benchmark suite ships alongside the code.
→ read the code and re-run it
github.com/v-code01/detrendwin