Data structure for discretely sampled continuous time trajectories

Maybe you can help me to order some thoughts: I am not sure if Discourse is the right tool/format, but I am happy for any feedback. In Bridge (GitHub - mschauer/Bridge.jl: A statistical toolbox for diffusion processes and stochastic differential equations. Named after the Brownian Bridge.) I am using a set of idiosyncratic structures as container for sample paths of continuous time random curves measured at discrete times. Think for example of Brownian motions at time points tt[1], tt[2], etc. I need a structure both as container for measurements and container for the output of random samplers. For my needs time can be a Float64 valued abstract array. I currently use

struct SamplePath{T} <: AbstractPath{T}
    tt::Vector{Float64} # I should not have forced a Vector here...
    yy::Vector{T}
end

But then the actual meaning changes a bit depending on context. For example tt can be the times where the process is at a known location, and between those times nothing is known, but in other settings I think of the path as piecewise linear or piecewise constant trajectory, with jumps at times tt. T is often Float64, or SArrays, or even a Gaussian struct containing SVector and SMatrix characterising location and uncertainty. When I work with higher dimensional data this is not the most convenient and I have also

struct VSamplePath{T} <: Bridge.AbstractPath{T}
    tt::Vector{Float64}
    yy::Matrix{T}
end

and VSamplePath and SamplePath can often be handled together using EllipsisNotation.jl.

I’d like to put some order structure into this, but do not yet see the light and most time series packages seem to put emphasis on handling object indexed by actual times.

If I understand you correctly, you are working with a mental model of event_time where time is measured as a duration between events and this measure increases at a constant rate and is understood to be relative to some observational starting timezero while the nature of an event is an occurrence observed occurring at a given time, either measured as time_of_occurence::Float64 or measured as time_elapsed_from_prior_occurace::Float64 (where timezero serves as the “initial prior occurrence”). Is this accurate?

I made a visualisation here: SamplePath - Nextjournal

1 Like

If you are asking about how to deal with the different interpretations (piecewise linear/constant, stochastic, scatter) and you want to handle those differently I would propose considering an extra type parameter to SamplePath representing that interpretation.

I thought about a hierarchy of structs, but thinking about it an additional type parameter seems to have the advantage that much less code duplication is needed.