Spectral Analysis
Fast Fourier Transform (FFT) and frequency domain metrics.
Analyzing a trajectory in the frequency domain is a powerful way to distinguish between periodic limit cycles and chaotic strange attractors.
Peak Frequency Extraction
The fft_peak_frequency() function performs a Fast Fourier Transform on a 1D time series (typically one coordinate of the trajectory) and identifies the dominant frequency component.
from hidden_attractors.analysis import fft_peak_frequency
# Assuming x is an array of shape (N, 3) representing a trajectory
# and dt is the integration step size (e.g., 0.01)
x1 = x[:, 0] # Extract the first coordinate
peak_freq, peak_power = fft_peak_frequency(x1, dt=0.01)
print(f"Dominant Frequency: {peak_freq:.3f} Hz")
If the system is a simple limit cycle, the FFT will show a single massive spike at the peak_freq, and smaller spikes at its harmonics.
Spectral Entropy
Chaotic attractors do not have a single dominant frequency; their energy is spread across a broad, continuous spectrum. We quantify this spread using Spectral Entropy.
The spectral_entropy() function (which requires the antropy optional dependency) computes the Shannon entropy of the power spectral density.
from hidden_attractors.analysis import spectral_entropy
# Measure the entropy of the x1 coordinate
entropy = spectral_entropy(x1, fs=1.0/0.01)
print(f"Spectral Entropy: {entropy:.3f}")
Interpretation
- Low Entropy (): The signal is highly predictable, likely a point attractor or a simple sine wave (limit cycle). All energy is concentrated in a few frequency bins.
- High Entropy: The signal is broadband and unpredictable. This is a strong indicator of deterministic chaos.