# TemporalGPs

TemporalGPs.jl is a tool to make Gaussian processes (GPs) defined using Stheno.jl fast for time-series. It provides a single-function public API that lets you specify that this package should perform inference, rather than Stheno.jl.

# Example Usage

```
using Stheno, TemporalGPs
# Specify a Stheno.jl GP as usual
f_naive = GP(Matern32(), GPC())
# Wrap it in an object that TemporalGPs knows how to handle.
f = to_sde(f_naive)
# Project onto finite-dimensional distribution as usual.
x = range(-5.0, 5.0; length=10_000_000)
fx = f(x, 0.1)
# Sample from the prior as usual.
y = rand(fx)
# Compute the log marginal likelihood of the data as usual.
logpdf(fx, y)
```

# Performance Optimisations

There are a couple of ways that `TemporalGPs.jl`

can represent things internally. In particular, it can use regular Julia `Vector`

and `Matrix`

objects, or the `StaticArrays.jl`

package to optimise in certain cases. The default is the former. To employ the latter, just add an extra argument to the `to_sde`

function:

`f = to_sde(f_naive, SArrayStorage(Float64))`

This tells TemporalGPs that you want all parameters of `f`

and anything derived from it to be a subtype of a `SArray`

with element-type `Float64`

, rather than (for example) a `Matrix{Float64}`

s and `Vector{Float64}`

. The decision made here can have quite a dramatic effect on performance, as shown in the graph below.

# Preliminary Benchmarking Results

"naive" timings are with the usual Stheno.jl inference routines, and is the default implementation for GPs. "lgssm" timings are conducted using `ssm`

with no additional arguments. "static-lgssm" uses the `SArray{Float64}`

option discussed above.

Gradient computations use Zygote. Custom adjoints have been implemented to achieve this level of performance.

# On-going Work

- Optimisation -- in particular work needs to be done to reduce the allocations made when the default storage is employed.
- Feature coverage -- only a subset of
`Stheno.jl`

's functionality is currently available, but it's possible to cover much more.

If you're interested in helping out with this stuff, please get in touch.

# Relevant literature

See chapter 12 of [1] for the basics.

[1] - Särkkä, Simo, and Arno Solin. Applied stochastic differential equations. Vol. 10. Cambridge University Press, 2019.

# Gotchas

- And time-rescaling is assumed to be a strictly increasing function of time. If this is not the case, then your code will fail silently. This could be addressed via careful engineering.