Vignette: Interpreting Dynamical Systems via Markov RQA, Hilbert Embeddings & Pole Scans
When analyzing empirical time series—such as river discharge anomalies, structural bridge vibrations, cardiac rhythms, or neural recordings—standard Recurrence Quantification Analysis (RQA) often misclassifies stochastic memory and amplitude decay as deterministic structure.
| Measured Phenomenon / Challenge | Standard RQA Failure Mode | SymbolicInference.jl Method |
|---|---|---|
| Autocorrelated stochastic drift (e.g., hydrology, climate, EEG background) | Serial correlation produces diagonal runs that i.i.d. nulls flag as deterministic | rqa_moments_test(...; null_model=:markov) |
| Damped oscillatory transient (e.g., structural impulse response, ringdown) | Shrinking amplitude collapses late points near zero, inflating RR | hilbert_unit_cylinder(...) |
| Two-mode interference (e.g., mechanical beating, dual-oscillator coupling) | Frequency beating modulates instantaneous phase speed | rqa_resonance_beating_test(...) |
| Regime shift / synchronization (e.g., seizure onset, lock-in, paired sensors) | Local transitions are masked by global averages or univariate smoothness | sliding_pole_scan(...), cross_coincidence_test(...) |
1. Hydrological / Climate Drift vs. Deterministic Dynamics (null_model=:markov)
Consider a 400-day recording of daily river-level or temperature anomalies modeled as an $\text{AR}(1)$ process ($x_t = 0.90 x_{t-1} + 0.42 \varepsilon_t$, autocorrelation timescale $\tau \approx 9.5$ days). Physically, this is pure stochastic red noise driven by daily random weather shocks—there is no deterministic oscillator or limit cycle.
using Random, RecurrenceAnalysis, SymbolicInference
rng = MersenneTwister(77)
n_ar = 400
x_ar = zeros(Float64, n_ar)
for t in 2:n_ar
x_ar[t] = 0.90 * x_ar[t - 1] + 0.42 * randn(rng)
end
emb_ar = hcat(x_ar[1:(n_ar - 4)], x_ar[5:n_ar])
rm_ar = RecurrenceMatrix(StateSpaceSet(emb_ar), 0.75)
ar_iid = rqa_moments_test(rm_ar; lmin=3, window_range=collect(2:20), null_model=:iid)
ar_mkv = rqa_moments_test(rm_ar; lmin=3, window_range=collect(2:20), null_model=:markov)
ar_iid["Global"]
# det_observed = 0.541, det_expected = 0.099, z_score = 48.0
ar_mkv["Global"]
# det_observed = 0.541, det_expected = 0.538, z_score = 0.04
ar_mkv["MarkovParams"].p11 # 0.527Interpretation of Results: Although $54.1\%$ (det_observed = 0.541) of recurrence points lie on diagonal lines of length $\ge 3$, the i.i.d. null expects only $9.9\%$ and reports $Z = 48.0$—mistaking slow hydrological memory for nonlinear determinism. Conditioning on the observed diagonal transition persistence $p_{11} = 0.527$ yields det_expected = 0.538 and $Z = 0.04$, correctly concluding that the trajectory is statistically indistinguishable from stochastic $\text{AR}(1)$ drift.
(To evaluate state trapping / Laminarity (LAM)—for instance, periods where a system stalls near a fixed level—set direction=:vertical.)
2. Structural Vibration Ringdown Under Exponential Damping (hilbert_unit_cylinder)
Consider a bridge or mechanical beam accelerometer sampled at $f_s = 512\text{ Hz}$ after an impulse strike, exciting a $f_0 = 32\text{ Hz}$ resonance that decays exponentially with time constant $\tau = 0.182\text{ s}$ ($\exp(-5.5 t)$) in sensor noise.
In a raw Euclidean delay embedding, once the vibration decays into the noise floor ($t > 0.3\text{ s}$), all late samples cluster near the origin, creating a spurious dense block in the upper-right recurrence plot (RR = 0.123). hilbert_unit_cylinder extracts the analytic signal and normalizes instantaneous amplitude onto the unit circle at the quarter-period lag d_q = compute_quarter_period_delay(fs, f0):
fs = 512.0
f0 = 32.0
t_ring = collect(0:299) ./ fs
h_ring = exp.(-5.5 .* t_ring) .* cos.(2π .* f0 .* t_ring) .+ 0.03 .* randn(rng, length(t_ring))
d_q = compute_quarter_period_delay(fs, f0) # d_q = 4 samples
hil = hilbert_unit_cylinder(h_ring; delay_samples=d_q, pad=48)
h_std = (h_ring .- mean(h_ring)) ./ std(h_ring)
N_cyl = size(hil.cylinder_4d, 1)
raw_emb = hcat(h_std[1:N_cyl], h_std[(1 + d_q):(N_cyl + d_q)])
rm_raw = RecurrenceMatrix(StateSpaceSet(raw_emb), 0.45)
rm_cyl = RecurrenceMatrix(StateSpaceSet(hil.cylinder_4d), 0.45)
RecurrenceAnalysis.recurrencerate(rm_raw) # 0.123 (biased by decay near origin)
RecurrenceAnalysis.recurrencerate(rm_cyl) # 0.064 (stationary phase diagonals)
runs = extract_phase_runs(hil.u, hil.v, d_q)
# prograde_rate = 0.936, max_run = 204
q_sub = encode_quadrant_symbols(hil.u, hil.v)[1:d_q:end]
wt = symbolic_word_test(q_sub, [1, 2, 3, 4]; alphabet_size=4, null_model=:iid)
# observed = 3, expected = 0.262, z_score = 5.42
Interpretation of Results:
- Left panel: On the $\text{AR}(1)$ drift series, the observed counts track the Markov 95% null band ($Z = 0.04$), whereas the i.i.d. baseline ($Z = 48.0$) drastically underpredicts persistence.
- Middle vs. Right panels: The raw recurrence plot (
RR = 0.123) confuses low-amplitude rest at late times with dynamical recurrence. The Hilbert unit-cylinder plot (RR = 0.064) removes amplitude decay and recovers uniform diagonal stripes corresponding to the $32\text{ Hz}$ phase cycle. - Symbolic metrics: A
prograde_rateof0.936(max_run = 204samples) and significant quadrant progression[1, 2, 3, 4]($Z = 5.42$) confirm that coherent single-mode phase rotation persists throughout the damped transient until the signal drops below the noise floor.
3. Multimode Beating, Regime Lock-In & Bivariate Sensor Coupling
A. Detecting Dual-Resonance Beating (rqa_resonance_beating_test)
When a vibrating structure or neural population excites two nearby modes ($32\text{ Hz}$ and $44\text{ Hz}$), interference modulates instantaneous phase velocity at $\Delta f = 12\text{ Hz}$:
t_b = collect(0:399) ./ fs
sig_1mode = exp.(-1.5 .* t_b) .* cos.(2π .* 32.0 .* t_b) .+ 0.025 .* randn(rng, length(t_b))
sig_2mode = exp.(-1.2 .* t_b) .* (cos.(2π .* 32.0 .* t_b) .+ 0.65 .* cos.(2π .* 44.0 .* t_b)) .+ 0.025 .* randn(rng, length(t_b))
res_1m = rqa_resonance_beating_test(sig_1mode, fs, 32.0, 44.0; epsilon=0.45, lmin=3)
# beat_power = 0.08, beat_score = 0.04
res_2m = rqa_resonance_beating_test(sig_2mode, fs, 32.0, 44.0; epsilon=0.45, lmin=3)
# beat_power = 228.2, beat_score = 258.09Interpretation: beat_power jumps from 0.08 (single mode) to 228.2 (two-mode superposition), directly distinguishing pure monochromatic damping from multimode interference.
B. Localizing Dynamical Lock-In (sliding_pole_scan)
Consider a sensor signal that transitions from $\text{AR}(1)$ background noise into a coherent $16\text{ Hz}$ oscillation (241 <= t <= 500, shaded gold) before returning to noise:
scan = sliding_pole_scan(x_shift, 100, 20; delay_samples=8, lmin=3)
# Noise segments: mean p11 = 0.439, persistence_gap = 1.404, mean Z = -3.71
# Locked segment: mean p11 = 0.988, persistence_gap = 0.013, mean Z = 4.08
Interpretation: During noisy idling, phase persistence is low (p11 = 0.439), the singularity gap 1/p11 - 1 remains wide (1.404), and Markov Z-scores stay negative. Upon entering the coherent oscillation, p11 approaches unity (0.988), the singularity gap collapses toward zero (0.013), and the Z-score crosses $+1.96$ (+4.08), pinpointing the onset and offset of phase lock-in.
C. Validating True Coupling Between Two Sensors (cross_coincidence_test)
Suppose two sensors record a chirped oscillation (x_cc, y_cc with a constant phase offset of $0.25\text{ rad}$), and we compare against an unrelated sensor exhibiting slow Brownian drift (y_rw):
t_cc = collect(0:219) ./ fs
ph_cc = 2π .* (18.0 .* t_cc .+ 45.0 .* (t_cc .^ 2))
x_cc = cos.(ph_cc) .+ 0.05 .* randn(rng, length(t_cc))
y_cc = cos.(ph_cc .+ 0.25) .+ 0.05 .* randn(rng, length(t_cc))
y_rw = cumsum(0.2 .* randn(rng, length(t_cc)))
cc_coupled = cross_coincidence_test(x_cc, y_cc; delay_samples=4, epsilon=0.45, lmin=3, n_slides=100, rng=rng)
# det_jrm = 0.944, sync_crm = 0.884, z_slide_crm = 21.55, composite_z = 14.29
cc_uncoupled = cross_coincidence_test(x_cc, y_rw; delay_samples=4, epsilon=0.45, lmin=3, n_slides=100, rng=rng)
# det_jrm = 0.776, sync_crm = 0.000, z_slide_crm = -0.48, composite_z = 0.86Interpretation: Even though the uncoupled random walk yields high marginal joint determinism (det_jrm = 0.776), circular time-slide calibration reveals zero zero-lag state coincidence (sync_crm = 0.000, composite_z = 0.86), whereas the phase-shifted coupled sensors achieve sync_crm = 0.884 and composite_z = 14.29.