FerroWave · guides

Getting started

Add ferro-wave to a Cargo workspace and decompose your first signal.

This guide walks through wiring ferro-wave into a Cargo workspace and running a multi-resolution decomposition on a price series end-to-end.

Add the dependency

Add ferro-wave to your crate's Cargo.toml from the approved MorphIQ package source for your workspace:

[dependencies]
ferro-wave = { version = "0.14" }
ferro-wave-finance = { version = "0.14" }

Decompose a signal

A discrete wavelet transform decomposes a signal x[n]x[n] of length N=2JN = 2^J into one approximation band aJa_J and JJ detail bands {dj}j=1J\{d_j\}_{j=1}^{J}:

x[n]=aJ[n]+j=1Jdj[n]x[n] = a_J[n] + \sum_{j=1}^{J} d_j[n]

Each detail band djd_j captures variation at scale 2j2^j. In code:

use ferro_wave::dwt::{Wavelet, decompose};
 
let signal: Vec<f64> = load_log_returns();
let levels = 5;
let mra = decompose(&signal, Wavelet::Db4, levels)?;
 
for (j, detail) in mra.details().iter().enumerate() {
    println!("level {}: energy = {:.4}", j + 1, detail.energy());
}

The transform is allocation-free past initial buffer setup and pure — the same inputs always produce the same output, which makes it safe to use on the hot path of a backtest or live regime detector.

Choosing a wavelet

  • Daubechies (Db2Db20) — orthogonal, compact support, the default for return-series work. Db4 is a reasonable starting point.
  • Symlets (Sym4Sym8) — near-symmetric Daubechies variants, useful when phase distortion matters.
  • Coiflets (Coif1Coif5) — higher vanishing moments per filter length, good for smooth signal approximation.

Match the vanishing moments of the wavelet to the polynomial order of the trend you want the approximation band to absorb.

Next steps

Read the MRA reference for the full multi-resolution API, or the regime primitives reference for the change-point and scale-energy estimators downstream products consume.