Created
November 13, 2019 13:44
-
-
Save m-pilia/f1e593163ed47eaa0df5e6aedb70b0ff to your computer and use it in GitHub Desktop.
Example sampling from a Gaussian Process prior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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