Giter Site home page Giter Site logo

Comments (4)

zugnachpankow avatar zugnachpankow commented on July 3, 2024

Hey @astrolitterbox / Simona,

thank you for reaching out with your problem!

Just for clearity, your input arrays are classical python or numpy arrays right? When you say you have shape (561, 2) arrays, that would mean an array of 561 arrays with length 2, in which the first entry is the timepoint and the second is your measurement. As far as i know, joint recurrence plot would consider your timepoints as part of a 2d data field then.

Therefore i would suggest converting your arrays into two (561, ) arrays, omitting the timepoints, as they are the same for both series. Please try to convert x and y in this way:

x_new = x[ : , 1]
y_new = y[ : , 1]

Then feed them to the method and let me know if that helped.

from pyunicorn.

astrolitterbox avatar astrolitterbox commented on July 3, 2024

Hi @zugnachpankow! Thank you so much for your quick response. Indeed, the arrays should have been flipped. I've tried doing that before.
Unfortunately, having 1D Numpy arrays does not change the result:


(150,)
(150,)
Calculating recurrence plot at fixed threshold...
Calculating the supremum distance matrix...
Calculating joint recurrence plot at fixed threshold...
[[1 1]
 [1 1]]

Here's a cleaned-up script that produces it: https://gist.github.com/astrolitterbox/54cdbcaf02f15e39d919078332397646

Many thanks for your help!

from pyunicorn.

fkuehlein avatar fkuehlein commented on July 3, 2024

Another class inheritance problem? @ntfrgl please help:

As described above, for two timeseries of length N, JointRecurrencePlot should produce a recurrence matrix of shape (N, N), but will end up with a matrix of shape (2, 2) irrespective of the input timeseries (see minimal example below).

In the example case, the recurrence matrix is calculated in JointRecurrencePlot.set_fixed_threshold(), which will call RecurrencePlot.distance_matrix(), which will call RecurrencePlot.supremum_distance_matrix().

The latter is fine, as with jrp = JointRecurrencePlot(), manually calling RecurrencePlot.supremum_distance_matrix(jrp) will produce a correctly shaped (50,50)-matrix.
Instead, manually calling RecurrencePlot.distance_matrix(jrp, jrp.x_embedded, metric="supremum") will produce a (2,2) shaped matrix (see below). Why?

Is there a problem with initialising a RecurrencePlot from an empty array in JointRecurrencePlot.__init__() maybe?


minimal example:

from pyunicorn.timeseries import JointRecurrencePlot
from pyunicorn.funcnet import CouplingAnalysis
# test timeseries of length N = 50
ts = CouplingAnalysis.test_data()[:50,0]
# create JointRecurrencePlot
jrp = JointRecurrencePlot(ts, ts, threshold=(.1,.1))
# compare input and output shapes
print(f"Timeseries shape:        {ts.shape}")
print(f"Recurrence Matrix shape: {jrp.recurrence_matrix().shape} <-- this is not right!\n")
# directly call parent class methods for comparison
print(f"the matrix calculation itself is ok:\
      {RecurrencePlot.supremum_distance_matrix(jrp, jrp.x_embedded).shape}")
print(f"but its not retrieved correctly:    \
      {RecurrencePlot.distance_matrix(jrp, jrp.x_embedded, metric='supremum').shape}")

output:

Calculating recurrence plot at fixed threshold...
Calculating the supremum distance matrix...
Calculating joint recurrence plot at fixed threshold...
Timeseries shape:        (50,)
Recurrence Matrix shape: (2, 2) <-- this is not right!

Calculating the supremum distance matrix...
the matrix calculation itself is ok:      (50, 50)
but its not retrieved correctly:          (2, 2)

from pyunicorn.

fkuehlein avatar fkuehlein commented on July 3, 2024

@ntfrgl, thanks for fixing and for providing a test that sets a good example!

from pyunicorn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.