rusandris / StateTransitionNetworks.jl

Toolkit for dynamics on state transition networks
1 stars 0 forks source link

Incorrect grid cell assignment in `time_series_to_grid` #20

Closed rusandris closed 3 months ago

rusandris commented 4 months ago

In some cases, incorrect grid cell assignment happens:

using DynamicalSystems
using StateTransitionNetworks

psos = StateSpaceSet(SVector{2, Float64}[[-5.2552322250639385, -7.219052646075152], [1.5664443644123152, -3.9662500474676654], [3.1763087630257547, -2.1920128718751686], [5.970316527128585, -2.138064814182889], [6.577608306947769, -1.889647777177131], [8.191453701781594, -0.03473035961559595], [-7.261347529773515, -3.9392525806007486]])

timeseries_to_grid(psos,5) #should return symbols between 1 and 25

Yet overflow happens and we get a 30 symbol:

7-element Vector{Int64}:
  1
 13
 19
 20
 20
 30
 11
rusandris commented 4 months ago

This is due to round-off errors. In timeseries_to_grid! , extending the grid borders by 100 consecutive floats doesn't always work

y_max_plus = nextfloat(y_max,100)

y_max_plus > y_max
 true

but

y_max_plus - y_min == y_max - y_min
 true

A more robust method is needed. x or y values that would determine the grid borders (that fall on the edges) should be excluded from partitioning.

rusandris commented 4 months ago

See fix here 968e697

rusandris commented 4 months ago

If there are points outside of the predefined grid, symbols can still be bigger than grid_size or grid_size^2. In that case, points outside should be discarded/warnings should be thrown.

Moved to #21

rusandris commented 3 months ago

See in d318cd1