FerroWave · examples
Regime / Hurst
Estimate regime state and the Hurst exponent from wavelet scale energy.
estimate_hurst_exponent fits a power-law slope to wavelet-leader scaling and
returns a typed HurstResult with the Hurst exponent and a confidence interval.
Track it over a rolling window for a regime classifier that needs no labelled
training data.
When to use it
- You want an unsupervised regime signal: is martingale (Brownian), mean-reverts, trends.
- You want a confidence interval on the estimate, not just a point value, before switching a strategy.
- You want a guard against feeding integrated inputs (prices) that would saturate the estimator.
Example
use ferro_wave::{Daubechies, DaubechiesType};
use ferro_wave::analysis::multifractal::{
estimate_hurst_exponent, HurstResult, MultifractalConfig};
let wavelet = Daubechies::new(DaubechiesType::Db4);
let config = MultifractalConfig::for_hurst_only();
let h: HurstResult = estimate_hurst_exponent(
&log_returns, &wavelet, Some(config))?;
if h.saturated {
// integrated input (prices, log-prices) — not a regime signal
skip_regime_switch();
} else {
match h.hurst_exponent {
x if x < 0.45 => switch_to_mean_revert(),
x if x > 0.55 => switch_to_trend_follow(),
_ => keep_neutral(),
}
}
// h.confidence_interval — half-width at config.confidence_level
// h.r_squared — log-log fit quality
# Ok::<(), ferro_wave::WaveletError>(())Notes
- Feed log-returns, not prices. An integrated input pins the estimator at
the boundary and sets
saturated = truerather than silently returning . - The full multifractal spectrum
H(q)is available via the same wavelet-leader estimator when you need intermittency, not just a single Hurst exponent.