Skip to content

Instantly share code, notes, and snippets.

@m-pilia
Created November 13, 2019 13:44
Show Gist options
  • Save m-pilia/f1e593163ed47eaa0df5e6aedb70b0ff to your computer and use it in GitHub Desktop.
Save m-pilia/f1e593163ed47eaa0df5e6aedb70b0ff to your computer and use it in GitHub Desktop.
Example sampling from a Gaussian Process prior
using Distributions
using LinearAlgebra
using Plots
using Random
pyplot();
N = 500;
M = 5;
ϵ = 1e-6 * rand() * I;
X = collect(range(0, stop=10, length=N));
k(x, y) = exp(-0.5 * norm(x - y)^2);
Σ = [k(X[i], X[j]) for i in 1:N, j in 1:N] + ϵ;
d = MvNormal(zeros(N), Σ);
f = rand(d, M);
p = plot(X, f);
display(p);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment