Last active
May 23, 2019 10:54
-
-
Save theogf/9cdab4eaecdc5e7d80020a688fe03002 to your computer and use it in GitHub Desktop.
Student-T GP Augmented model model
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 Turing | |
using MLKernels | |
using LinearAlgebra | |
N=100 | |
X = sort(rand(N,1),1) #Create some data | |
K = kernelmatrix(SquaredExponentialKernel(100.0),X) #Kernel matrix | |
y = rand(MvNormal(zeros(N),K+1e-1I)) #Sample from the GP prior with some noise | |
# Model representing Student-T Likelihood => Normal(y|f,omega)IG(omega|nu/2,nu/2) | |
@model augmentedmodel(K,y,nu,f=ones(N)) = begin | |
omega = Vector{Real}(undef,N) | |
for i in 1:N | |
omega[i] ~ InverseGamma(0.5*(nu+1.0),0.5*(nu+(y[i]-f[i])^2)) | |
end | |
Sigma = Symmetric(inv(Diagonal(inv.(omega))+inv(K+1e-3I))) #Jittering is added on K | |
f ~ MvNormal(Sigma*(y./omega),Sigma) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment