Created
February 1, 2023 15:22
-
-
Save astrolitterbox/54cdbcaf02f15e39d919078332397646 to your computer and use it in GitHub Desktop.
JRP case test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from pyunicorn.timeseries import RecurrencePlot, RecurrenceNetwork, CrossRecurrencePlot, JointRecurrencePlot | |
def logistic_map(x0, r, T): | |
""" | |
Returns a time series of length T using the logistic map | |
x_(n+1) = r*x_n(1-x_n) at parameter r and using the initial condition x0. | |
INPUT: x0 - Initial condition, 0 <= x0 <= 1 | |
r - Bifurcation parameter, 0 <= r <= 4 | |
T - length of the desired time series | |
TODO: Cythonize | |
""" | |
# Initialize the time series array | |
timeSeries = np.empty(T) | |
timeSeries[0] = x0 | |
for i in range(1, len(timeSeries)): | |
xn = timeSeries[i-1] | |
timeSeries[i] = r * xn * (1 - xn) | |
return timeSeries | |
# Parameters of logistic map | |
r = 3.679 # Bifurcation parameter | |
x0 = 0.7 # Initial value | |
# Length of the time series | |
T = 150 | |
# Settings for the embedding | |
DIM = 1 # Embedding dimension | |
TAU = 0 # Embedding delay | |
# Settings for the recurrence plot | |
EPS = 0.05 # Fixed threshold | |
RR = 0.05 # Fixed recurrence rate | |
# Distance metric in phase space -> | |
# Possible choices ("manhattan","euclidean","supremum") | |
METRIC = "supremum" | |
# | |
# Main script | |
# | |
# Create a time series using the logistic map | |
x = logistic_map(x0, r, T) | |
y = logistic_map(0.9, 3.680, T) | |
time_points = range(0, T) | |
print(x.shape) | |
print(y.shape) | |
jrp = JointRecurrencePlot(x, y, threshold=(0.1,0.1)) | |
print(jrp.recurrence_matrix()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment