Skip to content

Instantly share code, notes, and snippets.

@jrevels
Created October 8, 2018 19:58
Show Gist options
  • Save jrevels/cfd0af1e09321b0e990a552bb5fb4c88 to your computer and use it in GitHub Desktop.
Save jrevels/cfd0af1e09321b0e990a552bb5fb4c88 to your computer and use it in GitHub Desktop.
# Basic example.
using Stheno
using Stheno: GPC
# Define model.
function gp(σ, l)
g = GP(EQ(), GPC())
f = σ * g ∘ (x->l * x)
return g, f
end
x = collect(range(-5.0, stop=5.0, length=1000));
# Generate toy data from prior.
g, f = gp(1.0, 2.0)
f_ = rand(f(x))
function lml(θ)
g, f = gp(θ[1], θ[2])
return logpdf(f(x), f_)
end
# Need to be able to differentiate this w.r.t. the input.
# Only tricky operation is the cholesky really.
lml([1.0, 2.0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment