Skip to content
DeepForgeby svx
All problems
HardOptimizationop-182

GP Acquisition Step

Problem

Compute a Gaussian process posterior at a query point with a squared-exponential kernel.

Using k(a, b) = exp(-(a - b) ** 2 / (2 * lengthscale ** 2)) and adding the observation noise to the diagonal, compute the posterior mean and standard deviation and then the UCB acquisition mean + kappa * std. Return [mean, std, ucb].

Hint

The posterior mean is k_star^T K^-1 y and the variance is k(x*, x*) minus k_star^T K^-1 k_star.

Test cases

case 1
in: [[0,1],[0,1],0.5,1,0.01,2]
expected: [0.5459202999227215,0.19092944382753016,0.9277791875777819]
case 2
in: [[0,1],[1,2],0.25,0.5,0.1,1.5]
expected: [1.1766363616344027,0.49890091581250007,1.9249877353531528]
case 3
in: [[0,2],[0,0],1,1,0.05,1]
expected: [0,0.6158587938730616,0.6158587938730616]
Starter codePython
def gp_acquisition_step(X, y, x_star, lengthscale, noise, kappa):
    # Returns [mean, std, ucb]
    # Your code here
    pass

3 test cases · run your code against them in the editor