Skip to content
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

added history to mackey_glass #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arashgmn
Copy link

@arashgmn arashgmn commented Jul 19, 2023

Currently, delayed differential equations (DDE) such as Mackey-Glass are initialized with random history. Yet, for certain tasks, it is desirable to directly set the history. Consider estimating the Lyapunov exponent, for instance. One may want to generate two trajectories with initial conditions $d_0$ apart. The initial condition of DDE, however, also includes the historical record of the process. Thus, a correct setup must use the following definition of distance:

$\textbf d^2_{ij} = \frac{1}{\tau}\int_ {t=-\tau}^0 || \textbf{x}_i(t) - \textbf{x}_j(t) ||^2 dt$

which in discrete case translates into:

$\textbf d^2_{ij} = \Big[ \delta x[0]^2 + ( \delta x[-1]^2 + \delta x[-2]^2 + ... + \delta x[-\tau/dt]^2 ) \Big] $

This PR provides the possibility to directly provide the historical sequence to the mackey_glass process via an argument history. It asserts the length of the provided array. If it is long enough, enqueues the most recent elements to the history queue, otherwise and error will be raised. The default is set to None which initializes history randomly, as usual.

Copy link
Collaborator

@nTrouvain nTrouvain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @arashgmn,
Thank you so much for your contribution! We would really like to integrate it to reservoirpy.
I just made a small comment on the nature and content of the check you perform on the history variable. Also, if it is possible for you, could you add some elements to the datasets unit tests to check that your check passes correctly, and maintain coverage over this function?

x0 * np.ones(history_length) + 0.2 * (rs.random(history_length) - 0.5)
)
else:
assert int(round(tau / h)) <= len(history), \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a ValueError. AssertionError are not specific enough. And maybe the error text is a bit puzzling: maybe you could just state that history must have a length of a specific value, and add in parenthesis that this value is equal to tau/h ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants