A trend can dominate the finite-window spectrum
Construct x(t) = 10 + 0.05t + 2 cos(2π × 10.5t/128), for integer t = 0,...,127. These are invented values in arbitrary units, not observed prices. The oscillation has amplitude 2 and period 128/10.5 = 12.190476 bars. The table reports the largest non-DC bin, excluding k = 0, and the one-sided amplitudes from the executable code below. All values use the same 128 observations and six-decimal rounding.
- Subtracting the mean removes the rectangular-window DC term but leaves the slope. The strongest nonzero bin still describes the trend across the record, not the constructed oscillation.
- Linear detrending subtracts the least-squares line fitted inside this window. It can also remove part of a slow oscillation. Detrending does not guarantee stationarity, and the rectangular bin-20 amplitude actually increases here.
- The 10.5-cycle tone falls between bins 10 and 11. Neither peak amplitude recovers 2 exactly. A corrected Hann spectrum still has off-bin amplitude loss, called scalloping.
- The Hann-weighted residual need not have zero mean even when the unweighted residual does. Its small DC value is expected; it is excluded from peak selection.
| Preprocessing | Window | DC amplitude | Peak bin k | Period N/k (bars) | Peak amplitude | Amplitude at k = 20 |
|---|---|---|---|---|---|---|
| None | Rectangular | 13.190625 | 1 | 128.000000 | 2.048773 | 0.021703 |
| Subtract mean | Rectangular | 0.000000 | 1 | 128.000000 | 2.048773 | 0.021703 |
| Linear detrend | Rectangular | 0.000000 | 11 | 11.636364 | 1.300061 | 0.088153 |
| Linear detrend | Periodic Hann | 0.015584 | 10 | 12.800000 | 1.697723 | 0.000772 |