Numerical Data

Numerical data in DynamicalSystems.jl is represented by a structure called Dataset

#DynamicalSystemsBase.DatasetType.

Dataset{D, T} <: AbstractDataset{D,T}

A dedicated interface for datasets, i.e. vectors of vectors. It contains equally-sized datapoints of length D, represented by SVector{D, T}, containing numbers of type T.

The internal data representation is more efficient than having a Matrix and also leads to faster numerical computation of other quantities (like e.g. entropies). However, it can be used exactly like a matrix that has each of the columns be the timeseries of each of the dynamic variables. trajectory always returns a Dataset.

For example,

ds = Systems.towel()
data = trajectory(ds, 1000) #this returns a dataset
data[:, 2] # this is the second variable timeseries
data[1] == data[1, :] # this is the first datapoint (D-dimensional)
data[5, 3] # value of the third variable, at the 5th timepoint

Use convert(Matrix, dataset) to create a Matrix, and convert(Dataset, matrix) to create a Dataset from a matrix. Notice: convert(Dataset, matrix) assumes that each column of the matrix represents one dynamic variable. If instead each column of the matrix represents a datapoint, use reinterpret(Dataset, matrix).

If you have various timeseries vectors x, y, z, ... pass them like Dataset(x, y, z, ...).

source


In essence a Dataset is simply a container for a Vector of SVectors. However, it is visually represented as a matrix, similarly to how numerical data would be printed on a spreadsheet (with time being the column direction). It also offers a lot more functionality than just pretty-printing. Besides the examples in the documentation string, you can also do:

using DynamicalSystems
hen == Systems.henon()
data = trajectory(hen, 10000)
for point in data
# do stuff with each datapoint (vector with as many elements as system dimension)
end

All functions of our ecosystem that manipulate and use data are expecting an AbstractDataset subtype. This allows us to define efficient methods that coordinate well with other packages, like e.g. neighborhood.

If given a matrix, we first convert to Dataset. This means that you should first convert your data to a Dataset if you want to call functions more than once, to avoid constantly converting.

Dataset IO

In addition to the above, we also offer (very basic) functions that read/write a Dataset from/to a delimited text file:

#DynamicalSystemsBase.read_datasetFunction.

read_dataset(file, V::Type{Dataset{D, T}}, delim::Char = '  '; skipstart = 0)

Read a delim-delimited text file directly into a dataset of dimension D with numbers of type T.

Optionally skip the first skipstart rows of the file (that may e.g. contain headers).

source

#DynamicalSystemsBase.write_datasetFunction.

write_dataset(file, dataset::AbstractDataset, delim = ' '; opts...)

Simply calls writedlm(f, dataset.data, delim; opts...) and writes the data in a delimited (text) format in file.

source


For example

using DynamicalSystems

ds = Systems.towel()
data = trajectory(ds, 1000)

# Write comma-delimited file:
write_dataset("test.csv", data, ',')
# Read comma-delimited file:
read_dataset("test.csv", Dataset{2, Float64}, ',')