A Minimal Working Example

Here, I sample from / fit a sparse gaussian process using Titsias’ results.

### R code

N_p = 5000  # num data for fit & pred
N_u = 15    # num pseudo data

N_IS_SMALL = (N_p <= 5000)

x_p = seq(-5, 5, length.out = N_p)
x_u = seq(-3, 3, length.out = N_u)

# K = ( Kpp Kpu )
# K = ( Kup Kuu )

if(N_IS_SMALL)
    Kpp = exp(-((matrix(rep(x_p, N_p), N_p, N_p) -
               t(matrix(rep(x_p, N_p), N_p, N_p)))/4)^2)

Kpu = exp(-((matrix(rep(x_p, N_u), N_p, N_u) -
             matrix(rep(x_u, each = N_p), N_p, N_u))/4)^2)

Kuu = exp(-((matrix(rep(x_u, N_u), N_u, N_u) -
           t(matrix(rep(x_u, N_u), N_u, N_u)))/4)^2)

Kuui = solve(Kuu + diag(N_u)*1e-10)

# Prior Sample

mu_param = t(t(rnorm(N_u)))
sigma_param = diag(N_u) * 1e-2

# Exact VFE

y = sin(x_p) + rnorm(N_p, 0, 0.25)
func_pres = 10
sigma_param = solve(func_pres * Kuui %*% t(Kpu) %*% Kpu %*% Kuui + Kuui)
mu_param = func_pres * sigma_param %*% Kuui %*% t(Kpu) %*% y

mu = Kpu %*% Kuui %*% mu_param
if(N_IS_SMALL)
    sigma = Kpp + Kpu %*% Kuui %*% (sigma_param - Kuu) %*% Kuui %*% t(Kpu)

plot(x_p, mu, type = "l")
if(N_IS_SMALL)
    arrows(x_p, mu - 2*sqrt(diag(sigma)),
           x_p, mu + 2*sqrt(diag(sigma)),
           length = 0.01, angle = 90,
           col = "#BEBEBE20")

SVI & FITC using C++ to follow.

2019

Gaussian Process Middle C

First of my experiments on audio modelling using gaussian processes. Here, I construct a GP that, when sampled, plays middle c the way a grand piano would.

~1 min read
Back to Top ↑

2018

Back to Top ↑