The time delay is taken to be the delay at which the derivative of the ADFD falls to 40% of its initial value. The actual time delay used for generating the time series is 17, and the estimated time delay is 15. Compare with Fig. 8 of Rosenstein et al. (1994). """ import numpy as np import matplotlib.pyplot as plt from nolitsa import data, delay sample = 0.25 x = data.mackey_glass(length=2500, a=0.2, b=0.1, c=10.0, tau=17.0, discard=500, sample=sample) dim = 7 maxtau = 50 tau = np.arange(maxtau) disp = delay.adfd(x, dim=dim, maxtau=maxtau) ddisp = np.diff(disp) forty = np.argmax(ddisp < 0.4 * ddisp[1]) print(r'Time delay %d' % forty) fig, ax1 = plt.subplots()
#!/usr/bin/env python # -*- coding: utf-8 -*- """Generate time series using the Mackey-Glass equation. Generates time series using the discrete approximation of the Mackey-Glass delay differential equation described by Grassberger & Procaccia (1983). Typical values of the parameters in the Mackey-Glass delay differential equation are: a = 0.2, b = 0.1, c = 10.0, and tau = 23.0 with the grid size n usually taken larger than 1000. """ import matplotlib.pyplot as plt from nolitsa import data x = data.mackey_glass(tau=23.0, sample=0.46, n=1000) # Since we're resampling the time series using a sampling step of # 0.46, the time delay of the resampled series is 23.0/0.46 = 50. plt.title('Mackey-Glass delay differential equation') plt.plot(x[50:], x[:-50]) plt.xlabel(r'$x(t - \tau)$') plt.ylabel(r'$x(t)$') plt.show()
#!/usr/bin/env python # -*- coding: utf-8 -*- """D2 for the Mackey-Glass system. The estimates here are, depending on the initial condition, sometimes lower than the value (D2 ~ 2.4) calculated by Grassberger & Procaccia (1983). One should use average over an ensemble of initial conditions in such a case. """ import numpy as np import matplotlib.pyplot as plt from nolitsa import d2, data, utils x = utils.rescale(data.mackey_glass(tau=23.0, sample=0.46, n=1000)) # Since we're resampling the time series using a sampling step of # 0.46, the time delay required is 23.0/0.46 = 50. tau = 50 dim = np.arange(1, 10 + 1) plt.title('Local $D_2$ vs $r$ for Mackey-Glass system') plt.xlabel(r'Distance $r$') plt.ylabel(r'Local $D_2$') for r, c in d2.c2_embed(x, tau=tau, dim=dim, window=100, r=utils.gprange(0.001, 1.0, 100)): plt.semilogx(r[3:-3], d2.d2(r, c), color='#4682B4') plt.semilogx(utils.gprange(0.001, 1.0, 100), 2.4 * np.ones(100),
length_ms_hom_short = 60 length_ms_hom_long = 240 length_ms_het = 240 series_per_dataset = 100 frequency = 12 no_of_datasets = 100 # create the data folder if not existing if not os.path.exists('data'): os.makedirs('data') ########### SS and MS-Hom-Short Scenarios all_series = list() for dataset in range(no_of_datasets): ts = data.mackey_glass(length=length_ss, sample=5) min = np.min(ts) if min < 0: ts = ts - min if min < 1: ts = ts + 1 all_series.append(ts) # SS scenario required_multiples_list = list([100]) for dataset_index in range(no_of_datasets): output_path_ss = "./data/mackey_glass_dgp_ss_dataset_" + str(dataset_index + 1) + ".txt" with open(output_path_ss, "a") as data_file_object: ts = all_series[dataset_index] for multiple in required_multiples_list:
of the delayed mutual information (DMI) of the series. The probabilities required for its computation are estimated by binning the time series. For many examples, the DMI at a lag of zero computed with 2^m bins is approximately m bits. This is because the distribution is nearly flat when the number of bins is small, making the probability of being in a bin ~ 2^-m. Surprisingly, using a small number of bins doesn't seem to affect the estimation of the delay. Even with two bins, the extremas of the DMI are clearly visible. (Why?) """ import numpy as np import matplotlib.pyplot as plt from nolitsa import data, delay x = data.mackey_glass() plt.title(r'Delayed mutual information for the Mackey-Glass system') plt.xlabel(r'$\tau$') plt.ylabel(r'$I(\tau)$') for bins in (2**np.arange(1, 8 + 1)): ii = delay.dmi(x, maxtau=500, bins=bins) plt.plot(ii, label=(r'Bins = $%d$' % bins)) plt.legend() plt.show()