CSchoel / nolds

Nonlinear measures for dynamical systems (based on one-dimensional time series)
MIT License
255 stars 57 forks source link

How to obtain the correct corr dim for Lorenz attractor. #38

Open ricardofrantz opened 10 months ago

ricardofrantz commented 10 months ago

Hi Christopher,

I'd like to extend my gratitude for developing such a library. I've chosen to raise a topic in the issues section, anticipating that others may also find it relevant. I aim to utilize your package to calculate the correlation dimension of various dynamical systems. However, to have confidence in the outcomes, I need to be able to replicate the commonly referenced dimension value of d=2.05±0.01 for the Lorenz attractor with (sigma, rho, beta)=(10, 28, 8/3). Ideally, my goal is to generate a figure akin to the one attached. I find it perplexing that most packages, despite claims of this capability, seldom demonstrate this value in their documentation or examples. Could you provide any guidance or examples that successfully achieve this benchmark?

Thanks for your time, Ricardo

Screenshot 2023-12-07 at 23 11 14
CSchoel commented 9 months ago

Hi Ricardo. :wave: Unfortunately, I only occasionally have time to work on nolds, but good settings for the Lorenz system are one of my priorities for the path to version 1.0. The current version that you get when you install directly via pip install git+https://github.com/CSchoel/nolds.git has a corresponding example that you can run with python -m nolds.examples lorenz. If you add debug_plot=True to the call that reconstructs the correlation dimension from the data of the variable y, you get the following plot:

corr_dim_y

With the y coordinate, you get closest to the prescribed value with d = 2.057. If you want to look at the values outside the "linear part" of the curve, you can substitute rvals = nolds.logarithmic_r(1, np.e, 1.1) with rvals = nolds.logarithmic_r(np.e**-1, np.e**4, 1.1).

The example code boils down to this:

import nolds
import nolds.datasets as nd
sigma = 10
rho = 28
beta = 8.0/3
start = [0, 22, 10]
n = 10000
skip = 10000
dt = 0.012
data = nd.lorenz_euler(n + skip, sigma, rho, beta, start=start, dt=dt)[skip:]
rvals = nolds.logarithmic_r(np.e**-1, np.e**2, 1.1)  # determined experimentally
corr_dim_args = dict(emb_dim=5, lag=10, fit="poly", rvals=rvals)
cdx = nolds.corr_dim(data[:, 0], **corr_dim_args)
cdy = nolds.corr_dim(data[:, 1], **corr_dim_args, debug_plot=True)
cdz = nolds.corr_dim(data[:, 2], **corr_dim_args)  

Unfortunately, it was not at all trivial to find good parameter settings for this experiment. My main issue is that I didn't find any example in the literature that reports all parameters, both for the simulation of the Lorenz system and the correlation dimension algorithm. If you come across such an example, I would be immensely grateful for a link.