Open Family Office Datasets Tickers Strategies Portfolios Research Posts About Changelog

EMD: Empirical Mode Decomposition in Python

Source

Citation. Andrew J. Quinn, Vitor Lopes-dos-Santos, David Dupret, Anna Christina Nobre and Mark W. Woolrich (University of Oxford: the Oxford Centre for Human Brain Activity, the MRC Brain Network Dynamics Unit and the Department of Experimental Psychology). "EMD: Empirical Mode Decomposition and Hilbert-Huang Spectral Analyses in Python". Journal of Open Source Software 6(59), 2977, 31 March 2021. doi.org/10.21105/joss.02977. The paper is CC BY 4.0. The package: gitlab.com/emd-dev/emd, version 0.8.1, under the GNU General Public License v2 or later, by its PyPI metadata. The Medical Research Council, the NIHR Oxford Health Biomedical Research Centre, the Wellcome Trust, the James S. McDonnell Foundation and an EU training network funded the work. The method is from Huang et al. (1998), Proc. R. Soc. Lond. A 454, 903–995, which this page didn't read.

Status. Not applicable for now. No strategy uses spectral features, and the checks below show how a sift of the whole series fakes an edge. The harness gains a rule from it.

Read. Read on 2026-11-28. I read the JOSS paper from its text, which I extracted myself from the PDF. A subagent read the package's documentation pages on its sift functions and their options. I installed version 0.8.1 in a scratch environment, read its default configuration, and ran the checks below on simulated random walks and white noise. Huang et al. (1998) refused the fetch, and I found no study of EMD in finance that sifts only the past.

Summary

Claim. EMD separates a signal into intrinsic mode functions (IMFs), oscillations whose frequency and amplitude can change over time, plus a trend. The paper says that the sift "works on adaptive, local data segments without prescribing that features remain consistent across the entire signal." The package was written for neuroscience signals.

Method. The sift "looks to isolate the fastest dynamics in a time-series by iteratively sifting out slower dynamics". It subtracts the mean of the upper and lower envelopes, which splines draw through the local extrema, until that mean is near zero. That gives one IMF. The sift repeats on what is left. The package has the classic sift, the ensemble sift (Wu and Huang, 2009), the masked sift and a second sift of the IMFs' amplitudes. It computes instantaneous phase, frequency and amplitude by the Hilbert transform, and the Hilbert–Huang spectrum. Its defaults come from the installed configuration. Each IMF stops on the standard-deviation rule at 0.1, after at most 1,000 iterations. The envelopes are cubic splines, with two extrema of padding at each end, reflected.

Findings, from my checks. Random walks with daily volatility of 1%, and white noise.

Setting Number Value
IMF 1 at the newest bar, sifted on the past only, against its value after 50 more bars correlation 0.10
IMF 1 a hundred bars back, the same comparison correlation 1.000
The slope of the series less its two fastest IMFs, as a forecast of the next return's sign, sifted on the whole series hit rate on random walks 60.3% (standard error 0.4 points, 15,920 forecasts)
The same, sifted on data up to each bar only hit rate 50.5% (standard error 1.1 points, 1,992 forecasts)
White noise, the IMFs' mean periods bars 2.9, 7.3, 17.8, 42.4, 102, 250, 611
The same ratio of successive periods about 2.4

Where the claims go beyond the evidence

"Local" isn't "past". The sift is local in time, but each IMF at a bar depends on the extrema on both sides of it, later ones included. So a value from a sift of the whole series uses the future. My check shows the size of it. On random walks with no edge, a forecast from the full-sample sift was right 60.3% of the time, a false edge of ten points. Sifted on the past only, the same forecast was right 50.5% of the time. A study that sifts the whole series and then reports accuracy has probably measured this leak.

The newest values are the least reliable. At the end of the series, the envelope has no extrema beyond the last bar, so the padding sets it. The newest IMF 1 value correlated only 0.10 with its value once 50 more bars had arrived. A hundred bars back, the values didn't change. So the one value a trader can use is the one the method is least sure of.

EMD finds cycles in noise. On white noise the sift gave seven IMFs, with periods that grow by about 2.4 times each. That is the filter bank that Wu and Huang (2004) and Flandrin et al. (2004) describe. An IMF in a price series is a signal only if it differs from what noise gives. A test against surrogate data must come before any cycle is called real.

The decomposition has many settings. The stopping rule, its threshold, the spline, the padding, and the ensemble's noise and size each change the IMFs. Each choice is a trial.

Inconsistencies. The documentation's defaults disagree with the code in two places, by the subagent's reading. mask_sift's docstring gives a default of ratio_imf against ratio_sig in its signature. complete_ensemble_sift documents a noise_mode that its signature lacks. The installed package raised NumPy's warning that a where "used without 'out'" leaves "uninitialized memory in output", in its energy calculation.

Credit. The package documents its algorithms and their sources, exposes every setting in one configuration object that can be saved, and is tested.

Use in this repo

A rule for the harness: a feature's past must not change. The harness's oracle (oracle.py) already checks that the feed never shows a bar after now. So a strategy that sifts inside the loop, from the feed, sifts the past only. The risk is a feature series computed once on all of history and stored, then read by a strategy. The check that catches it is simple. Compute the feature on data to a date, then again with more data, and compare the values before that date. They must be identical. A sift of the whole series fails at once. So does a full-sample Fourier fit (fft-price-prediction.md), a two-sided smoother (statsmodels.md) or a centred moving average. The check is pointintime.check, which harness.Settings.features runs on each precomputed feature (#370). For now it warns, and the verdict ignores it.

If EMD is ever used, use it on the past only. The sift must be recomputed at each bar on data up to that bar. Then the newest values are unstable, and the false edge disappears. A past-only EMD feature still needs its own out-of-sample test, a comparison with noise, and every setting counted as a trial (#7, #11, #89).

The licence matters for a dependency. The package is GPL v2 or later. The project would have to accept that licence's terms to depend on it, so a past-only check in a test is the more likely use.

The other spectral sources. #247 (Fourier and volatility), #248 (wavelets), #249 (Fourier features for a GRU) and #251 (ARIMA with Fourier features) need the same check. TA-Lib's Hilbert-transform indicators (ta-lib.md) pass the rule: I checked that HT_DCPHASE, HT_DCPERIOD and HT_TRENDLINE give identical values at each bar with or without later data. They still have TA-Lib's warm-up.