Analyzing Resonant Manifolds
Given a dataset or signal exhibiting periodic/field-like behavior, extract its resonant modes and map them onto a manifold representation:
Pythonimport numpy as np from scipy.signal import find_peaks from sklearn.decomposition import PCA def extract_resonant_modes(signal, sample_rate, n_components=3): # 1. Frequency domain transform spectrum = np.abs(np.fft.rfft(signal)) freqs = np.fft.rfftfreq(len(signal), 1/sample_rate) # 2. Find resonant peaks peaks, props = find_peaks(spectrum, prominence=spectrum.max() * 0.05) resonant_freqs = freqs[peaks] resonant_amps = spectrum[peaks] # 3. Build phase-space embedding (manifold candidate) embedding = np.column_stack([ np.roll(signal, i) for i in range(n_components) ])[n_components:] # 4. Reduce to low-dim manifold manifold = PCA(n_components=n_components).fit_transform(embedding) return { "resonant_freqs": resonant_freqs, "resonant_amps": resonant_amps, "manifold": manifold }
Output: a set of resonant frequencies/amplitudes plus a low-dimensional manifold embedding ready for visualization or further tuning.
Progress:
- Step 1: Characterize the raw signal/dataset (sample rate, dimensionality, noise floor)
- Step 2: Transform into frequency or phase space
- Step 3: Detect resonant peaks/modes with prominence filtering
- Step 4: Construct a time-delay or feature embedding
- Step 5: Reduce embedding to a manifold (PCA/UMAP/t-SNE depending on scale)
- Step 6: Validate stability of modes (re-run on sub-windows, check consistency)
- Step 7: Flag anomalies — modes that appear/disappear or drift significantly
- Step 8: Report resonant structure with confidence/stability scores
Step 1 — Characterize input. Confirm sample rate, units, and whether data is 1D (audio/signal) or multi-channel (field/sensor array). Note noise floor via a quiet/baseline segment.
Step 2 — Transform. Use FFT for periodic signals; use delay embedding directly for chaotic/nonlinear systems where frequency content alone is insufficient.
Step 3 — Detect modes. Prominence-based peak detection avoids false positives from noise. Prominence threshold should scale with the noise floor, not a fixed constant.
Step 4–5 — Embed and reduce. Time-delay embedding dimension should exceed estimated system dimensionality by at least 2 (Takens' theorem heuristic). Use PCA for speed, UMAP for nonlinear manifold structure when PCA explains <80% variance in first 3 components.
Step 6 — Validate. Split signal into overlapping windows; recompute modes. Modes present in >70% of windows are "stable resonances." Others are transient.
Step 7 — Anomaly flagging. Compare mode amplitude/frequency drift across windows using z-scores relative to the stable-mode population.
Example 1: Input: A 10-second audio recording (44.1kHz) of a bowed metal plate, suspected to have multiple harmonic resonances plus one subharmonic artifact. Output: Resonant frequencies at [220Hz, 440Hz, 660Hz] (stable across 92% of windows) and a flagged anomalous mode at 110Hz present in only 15% of windows, tagged as a transient subharmonic artifact, not a true resonance.
Example 2: Input: Multichannel sensor array data (8 channels, field strength over time) from a generative installation. Output: 2D manifold embedding showing 3 dominant stable clusters corresponding to three "attractor states" of the installation, with one channel (#6) identified as noise-dominated (low signal-to-manifold-variance ratio) and excluded from final resonance report.
- Always baseline noise floor before setting peak-detection thresholds.
- Prefer stability-across-windows over single-pass detection — a single FFT peak can be noise.
- When embedding dimension is uncertain, sweep 2–8 and pick the elbow in explained variance.
- Report confidence/stability percentage alongside every detected mode, never raw peaks alone.
- For generative/art pipelines, keep the manifold low-dimensional (2–3D) for downstream visualization or parameter mapping.
- Don't treat every FFT peak as a "resonance" — validate persistence across time windows first.
- Don't use a fixed prominence threshold across datasets with different noise floors.
- Don't skip embedding-dimension sweeps — too low misses structure, too high overfits noise.
- Don't conflate transient artifacts (clicks, edge effects) with true resonant modes.
- Don't apply linear PCA to clearly nonlinear/chaotic systems without checking explained variance first.