Recurrence Analysis
Quantifying periodicity using Recurrence Quantification Analysis (RQA).
Recurrence Quantification Analysis (RQA) is a method for studying the structure of dynamical systems by looking at how often the trajectory returns to previously visited regions in phase space.
The hidden-attractors-fo library wraps the antropy package to provide fast recurrence metrics.
Note: You must have installed the library with the [analysis] extra to use this feature.
Recurrence Rate (REC)
The fundamental metric of a Recurrence Plot is the Recurrence Rate (REC). It represents the percentage of points in the trajectory that are within a small distance of each other (excluding points that are immediately adjacent in time).
from hidden_attractors.analysis import recurrence_rate
import numpy as np
# Extract the x1 coordinate
x1 = x[:, 0]
# Calculate the recurrence rate
# threshold (epsilon) determines how close points must be to count as a recurrence
rec = recurrence_rate(x1, threshold=0.1)
print(f"Recurrence Rate: {rec:.4f}")
Interpretation
- High REC (e.g., > 0.5): The system is highly periodic (a limit cycle). The trajectory constantly repeats its path.
- Low/Moderate REC (e.g., 0.01 - 0.1): The system is chaotic. It occasionally returns to similar states, but the motion is not strictly periodic.
- Very Low REC (): The system is noisy or a transient that never returns to previous states (e.g., a divergent trajectory).