FerroWave · examples

Adaptive / EMD

Adaptive decomposition with EMD and CEEMDAN for non-stationary signals.

Where DWT projects onto a fixed wavelet basis, Empirical Mode Decomposition lets the data pick the basis. emd sifts a signal into Intrinsic Mode Functions until a monotonic residual remains — the entry point into the whole adaptive family.

When to use it

  • Your signal is non-stationary and a fixed wavelet basis does not capture its local-frequency structure.
  • You want a data-driven decomposition with no basis to choose up front.
  • You want one result type across methods — emd, eemd, ceemdan, memd, vmd, ewt, and sswt all return IMFs, so downstream code is unchanged.

Example

use ferro_wave::Signal;
use ferro_wave::transform::{emd, EMDConfig, IMF};
 
let signal = Signal::new(log_returns.to_vec());
let config = EMDConfig::default()
    .with_max_imfs(6)
    .with_max_sifting_iterations(50);
 
let result = emd(&signal, &config)?;
 
for (i, imf) in result.imfs.iter().enumerate() {
    // imf.data — same length as signal
    // imf is band-limited around one local freq
}
// result.residual — monotonic trend
// result.orthogonality_index() — Huang 1998 Eq. 5.5
// result.mode_mixing_index()   — per-IMF spectral overlap
 
// Drop in CEEMDAN, MEMD, VMD, EWT, or SST for
// the same IMF contract over a different decomposer.
# Ok::<(), ferro_wave::WaveletError>(())

Notes

  • Every method preserves the reconstruction identity Σ IMFₖ + residual == signal exactly.
  • See Transforms for the rubric on choosing among EMD, CEEMDAN, MEMD, VMD, EWT, and SST.
  • The whole family also streams over a sliding window via the IncrementalTransform contract.