-
-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Largest Lyapunov Exponent (complexity_lyapunov method) - incorrect result for Lorenz system #900
Comments
Thanks for getting in touch. I can confirm that the plot works : If it doesn't show up try adding
That seems reasonable. Would you mind looking into the function and tell me what to change (or please consider making directly a PR). In general, I'm far from being an expert on this, so I'd appreciate any ways of improving / fixing / correcting this function. |
I have made a PR (#906 ) and added a new method, |
Hi Dominique, Yes no problem. I'll test over the weekend. I've thought about the core issue I reported last week. If we change the function so that it returns a set of average divergences, we can then plot them, in a similar manner to your example above. By plotting them and drawing a line with polyfit or curvefit, the user can then see the slope more readily. As an example, here is a plot I made using a different library and then by examining the plot, I then compute the slope and intercept and plot as a straight line by choosing only values of time where the average divergence is at the change point. As I noted, I'll do some testing on this new method over the weekend. Thanks, Anthony |
PS: you can install the PR using |
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Overview of Problem
I have been trying to get NeuroKit2 to give a suitable result for the Largest Lyapunov Exponent via the complexity_lyapunov method.
Before using it on a set of data such as EEG data, I wanted to validate that it would return valid results for a system for which we can explicity calculate the LE's using other very well tried and tested methods. Therefore you will not be surprised that I used the Lorenz system with the usual sigma (=10.0), rho (=28.0) and beta (=8.0/3.0) values and generated a data set of 10000 points.
Using the 'x' values only from this data set, I used the complexity_delay to calculate the lag (using Fraser1986, Rosenstein1993 options etc), the complexity_dimension to calculate the dimension (using AFN, CD and FNN options) and then pass the optimal values into the complexity_lyapunov method.
We know from other studies and methods that there are 3 LE's for the Lorenz system and the largest of which is ~0.9036. This is the value I was expecting back from the complexity_lyapunov method, however, it does not! It returns a value of 0.02048061575362412. This is signigicantly a long way off 0.9036.
Under the covers it appears that the complexity_lyapunov method is doing a least squares fit of the data to compute the slope (which should give the LLE) but in this case alas it does not appear to be correct.
Furthermore, if I set 'show=True', I was expecting a plot to appear but it doesn't.
To Reproduce
This will give you a data set that looks like this:
(Note: If you plot the states here you get a lovely reproduction of the classic butterfly)
So I had expected this to give me value close to the known LLE of the Lorenz system of ~0.9036 (the full spectra is: 0.9036597330935988 -0.0011701995833755246 -14.569053990750257 calculated using the Bennetin algorithm).
The output from the call to
nk.complexity_lyapunov()
above yields a result ofI suspect that this is 'one' of the LLE's computed at a specific time point but perhaps it would be prudent to put the full spectra of points into another dictionary item. within info.
Output of nk.versio()
OS: Darwin ( 64bit)
Python: 3.9.6
NeuroKit2: 0.2.5
NumPy: 1.24.3
Pandas: 2.1.0
SciPy: 1.10.1
sklearn: 1.3.0
matplotlib: 3.7.1
Any help gratefully received.
Thanks, Anthony
The text was updated successfully, but these errors were encountered: