Kernel functions

Radial Basis Function (RBF)

Given

$$ K(X_1,X_2)=\sigma^2\exp\left(-\frac{||X_1-X_2||^2}{2\ell^2}\right) $$

  • $\sigma^2$ is the overall variance (where $\sigma$ is also known as the amplitude) It determines the average distance of your function away from its mean. It can be interpreted as a scale factor.
  • $\ell$ the lengthscale. In general, you won’t be able to extrapolate more than $\ell$ units away from your data.
import numpy as np
from sklearn.gaussian_process.kernels import RBF

np.random.seed(42)

xlim = (-4, 4)
X = np.expand_dims(np.linspace(*xlim, num=75), 1)
zero = np.array([0.]())

amplitude = 1.0
Σ1 = (amplitude**2) * RBF(length_scale=1)(X)
Σ2 = (amplitude**2) * RBF(length_scale=0.5)(X)
amplitude = 0.5
Σ3 = (amplitude**2) * RBF(length_scale=1)(X)