rusandris / StateTransitionNetworks.jl

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

Symbolic time series with generating partitions #11

Open sbulcsu opened 6 months ago

sbulcsu commented 6 months ago

The timeseries_to_grid function should be able to generate a symbolic time series for predefined cell edges as well (e.g. generating partitions or Voronoi cells).

cell_edges = [0, 0.99, 1]
sts = timeseries_to_grid(timeseries, grid_size; grid_edges = cell_edges);

We could do something like this (assuming an ordered cell_edges list):

for (i,edge) in enumerate(cell_edges)
            if timeseries[i][1]>edge
                x = i
                continue
            end
end
symbolic_timeseries[i] =x

This is extremely slow, but we need to find the right cell for the actual state of the system.

rusandris commented 6 months ago

Maybe we should resort to something simple like this:


function timeseries_to_grid(timeseries::TimeSeries{T,1}, partition::Function)  where T <: Real    
  L = length(timeseries)

  symbolic_timeseries = Vector{Int64}(undef, L)

  for i in 1:L
  symbolic_timeseries[i] = partition(timeseries[i][1])
  end

  return symbolic_timeseries
end

allowing the total control over the partitioning scheme.

And then one can go

using StateTransitionNetworks,DynamicalSystems

function f(u, p, n)
  r = p[1]
  x = u[1]
  if x<=r
     return SVector(x/r)
  else
     return SVector((1-x)/(1-r))
  end
end

r = 0.99
ds = DeterministicIteratedMap(f, [0.4], [r])
orbit,t = trajectory(ds,10^4;Ttr=1000)

tent_generating_partition(x::Float64,r::Float64) = x <= r ? 1 : 2

sts = timeseries_to_grid(orbit,x -> tent_generating_partition(x,r))
rusandris commented 6 months ago

timeseries_to_grid methods that dispatch to partition::Function were pushed. We should think about implementing all previous gridding through this kind of method.