Application Scenarios
- Financial Analysis: Multifractal structure in stock prices and returns
- Physiological Signals: Heartbeat intervals, EEG, biosignals
- Climate Data: Long-range correlations in temperature/precipitation
- Geophysical Series: Earthquake, seismic, and tidal analysis
Usage Examples
Basic Usage
import numpy as np
from FreeAeonFractal.FASeriesMFS import CFASeriesMFS
x = np.cumsum(np.random.randn(5000)) # example: random walk
mfs = CFASeriesMFS(x, q_list=np.linspace(-5, 5, 21))
df_mfs = mfs.get_mfs()
print(df_mfs.head(10))
mfs.plot(df_mfs)
Custom Scale Windows
from FreeAeonFractal.FASeriesMFS import CFASeriesMFS, recommended_lag
x = np.cumsum(np.random.randn(10000))
lag = recommended_lag(len(x), order=2, num_scales=40)
mfs = CFASeriesMFS(x)
df_mfs = mfs.get_mfs(lag_list=lag, order=2)
print(df_mfs)
Installation (extra dependency)
pip install FreeAeon-Fractal MFDFA
Class Description
CFASeriesMFS
Initialization Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
data | array-like | Required | Input 1D time series |
q_list | array-like | linspace(-5,5,51) | q moment values |
with_progress | bool | True | Show progress bar |
get_mfs(lag_list=None, order=2)
Compute multifractal spectrum via MFDFA. lag_list: scale windows (auto if None). order: DFA polynomial order (1=mean, 2=linear, 3=quadratic).
Returns DataFrame with columns:
| Column | Description |
|---|---|
q | Moment order |
h(q) | Generalized Hurst exponent |
t(q) | Mass exponent τ(q) = q·h(q) − 1 |
a(q) | Singularity strength α(q) = dτ/dq |
f(a) | Multifractal spectrum f(α) = q·α − τ(q) |
d(q) | Generalized dimension D(q) = τ(q)/(q−1) |
plot(df_mfs)
2×3 subplots: H(q), τ(q), D(q), α(q), f(α) vs α, normalized overview.
recommended_lag(x_len, order=2, num_scales=40, s_min=None, s_max_ratio=0.25)
Generate geometrically spaced scale windows. Raises ValueError if sequence is too short.
Theoretical Background
MFDFA Algorithm
1. Profile: Y(i) = Σ_t x(t) - mean(x)
2. Segment into windows of size s (the lag)
3. Detrend each window with poly(order), compute F²(s,v)
4. Fq(s) = (1/N Σ [F²]^(q/2))^(1/q) for each q
5. Scaling: Fq(s) ~ s^h(q) → slope = h(q)
Key Metrics
h(q): generalized Hurst exponent (h(2) = standard Hurst)
τ(q) = q·h(q) - 1 mass exponent
α(q) = dτ/dq (np.gradient) singularity strength
f(α) = q·α - τ(q) multifractal spectrum
D(q) = τ(q) / (q-1) generalized dimension
Important Notes
- Sequence Length: Minimum ~1000 points recommended; below 500 results are unreliable
- q Range: Negative q → low-fluctuation regions; positive q → high-fluctuation; recommend linspace(-5,5,21)
- DFA Order: order=2 is standard; higher orders remove lower-frequency trends but need more data
- Multifractality: Δh > 0.1 suggests multifractality; check if D(q) decreases monotonically
- Dependency: Requires
pip install MFDFA
References
- Kantelhardt, J. W., et al. (2002). Physica A.
- Peng, C.-K., et al. (1994). Physical Review E.