# Data structure for discretely sampled continuous time trajectories

**URL:** https://discourse.julialang.org/t/data-structure-for-discretely-sampled-continuous-time-trajectories/14785
**Category:** General Usage
**Created:** [September 10, 2018, 9:27pm UTC](https://discourse.julialang.org/t/data-structure-for-discretely-sampled-continuous-time-trajectories/14785 "2018-09-10T21:27:23Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mschauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mschauer/32/13946_2.png) [@mschauer](https://discourse.julialang.org/u/mschauer)
#### Post date: [September 10, 2018, 9:27pm UTC](https://discourse.julialang.org/t/data-structure-for-discretely-sampled-continuous-time-trajectories/14785/1 "2018-09-10T21:27:23Z")

</div>

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.](https://github.com/mschauer/Bridge.jl)) 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

```julia
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 `SArray`s, 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

```julia
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.

---

<div class="post-metadata">

### Author: ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)
#### Post date: [September 11, 2018, 3:31am UTC](https://discourse.julialang.org/t/data-structure-for-discretely-sampled-continuous-time-trajectories/14785/2 "2018-09-11T03:31:05Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![mschauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mschauer/32/13946_2.png) [@mschauer](https://discourse.julialang.org/u/mschauer)
#### Post date: [September 11, 2018, 8:07am UTC](https://discourse.julialang.org/t/data-structure-for-discretely-sampled-continuous-time-trajectories/14785/3 "2018-09-11T08:07:21Z")

</div>

I made a visualisation here: [SamplePath - Nextjournal](https://nextjournal.com/mschauer/samplepath)

---

<div class="post-metadata">

### Author: ![axsk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/axsk/32/1952_2.png) [@axsk](https://discourse.julialang.org/u/axsk)
#### Post date: [September 11, 2018, 9:04am UTC](https://discourse.julialang.org/t/data-structure-for-discretely-sampled-continuous-time-trajectories/14785/4 "2018-09-11T09:04:03Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mschauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mschauer/32/13946_2.png) [@mschauer](https://discourse.julialang.org/u/mschauer)
#### Post date: [September 11, 2018, 10:37am UTC](https://discourse.julialang.org/t/data-structure-for-discretely-sampled-continuous-time-trajectories/14785/5 "2018-09-11T10:37:54Z")

</div>

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.
