Kernels#
- fvgp.kernels.squared_exponential_kernel(distance, length)[source]#
Function for the squared exponential kernel. kernel = np.exp(-(distance ** 2) / (2.0 * (length ** 2)))
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
length (scalar) – The length scale hyperparameters.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.squared_exponential_kernel_robust(distance, phi)[source]#
Function for the squared exponential kernel (robust version) kernel = np.exp(-(distance ** 2) * (phi ** 2))
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
phi (scalar) – The length scale hyperparameters.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.exponential_kernel(distance, length)[source]#
Function for the exponential kernel. kernel = np.exp(-(distance) / (length))
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
length (scalar) – The length scale hyperparameters.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.exponential_kernel_robust(distance, phi)[source]#
Function for the exponential kernel (robust version) kernel = np.exp(-(distance) * (phi**2))
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
phi (scalar) – The length scale hyperparameters.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.matern_kernel_diff1(distance, length)[source]#
Function for the Matern kernel, order of differentiability = 1. kernel = (1.0 + ((np.sqrt(3.0) * distance) / (length))) * np.exp(
-(np.sqrt(3.0) * distance) / length
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
length (scalar) – The length scale hyperparameters.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.matern_kernel_diff1_grad(distance, dist_der)[source]#
Function for the Matern kernel derivative, order of differentiability = 1. kernel = (1.0 + ((np.sqrt(3.0) * distance) / (length))) * np.exp(
-(np.sqrt(3.0) * distance) / length
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
dist_der (scalar or np.ndarray) – The derivative of the distance matrix. We assume here that the distance is a function of the hyperparameters.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.matern_kernel_diff1_robust(distance, phi)[source]#
Function for the Matern kernel, order of differentiability = 1, robust version. kernel = (1.0 + ((np.sqrt(3.0) * distance) * (phi**2))) * np.exp(
-(np.sqrt(3.0) * distance) * (phi**2))
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
phi (scalar) – The length scale hyperparameters.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.matern_kernel_diff2(distance, length)[source]#
Function for the Matern kernel, order of differentiability = 2. kernel = (
1.0 + ((np.sqrt(5.0) * distance) / (length)) + ((5.0 * distance ** 2) / (3.0 * length ** 2))
) * np.exp(-(np.sqrt(5.0) * distance) / length)
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
length (scalar) – The length scale hyperparameters.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.matern_kernel_diff2_robust(distance, phi)[source]#
Function for the Matern kernel, order of differentiability = 2, robust version. kernel = (
1.0 + ((np.sqrt(5.0) * distance) * (phi**2)) + ((5.0 * distance ** 2) * (3.0 * phi ** 4))
) * np.exp(-(np.sqrt(5.0) * distance) * (phi**2))
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
phi (scalar) – The length scale hyperparameters.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.sparse_kernel(distance, radius)[source]#
Function for a compactly supported kernel.
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
radius (scalar) – Radius of support.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.periodic_kernel(distance, length, p)[source]#
Function for a periodic kernel. kernel = np.exp(-(2.0/length**2)*(np.sin(np.pi*distance/p)**2))
- Parameters:
distance (scalar or np.ndarray) – Distance between a set of points.
length (scalar) – Length scale.
p (scalar) – Period.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.linear_kernel(x1, x2, hp1, hp2, hp3)[source]#
Function for a linear kernel. kernel = hp1 + (hp2*(x1-hp3)*(x2-hp3))
- fvgp.kernels.dot_product_kernel(x1, x2, hp, matrix)[source]#
Function for a dot-product kernel. kernel = hp + x1.T @ matrix @ x2
- Parameters:
x1 (np.ndarray) – Point 1.
x2 (np.ndarray) – Point 2.
hp (float) – Offset hyperparameter.
matrix (np.ndarray) – PSD matrix defining the inner product.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.polynomial_kernel(x1, x2, p)[source]#
Function for a polynomial kernel. kernel = (1.0+x1.T @ x2)**p
- Parameters:
x1 (np.ndarray) – Point 1.
x2 (np.ndarray) – Point 2.
p (float) – Power hyperparameter.
- Returns:
Kernel output
- Return type:
same as distance parameter.
- fvgp.kernels.wendland_kernel(d)[source]#
Function for the Wendland kernel with a given distance matrix. The Wendland kernel is compactly supported, leading to sparse covariance matrices.
- Parameters:
d (np.ndarray) – Distance matrix.
- Returns:
Covariance matrix
- Return type:
np.ndarray
- fvgp.kernels.wendland_anisotropic(x1, x2, hyperparameters)[source]#
Function for the Wendland kernel. The Wendland kernel is compactly supported, leading to sparse covariance matrices.
- Parameters:
x1 (np.ndarray) – Numpy array of shape (U x D).
x2 (np.ndarray) – Numpy array of shape (V x D).
hyperparameters (np.ndarray) – Array of hyperparameters. For this kernel we need D + 1 hyperparameters.
- Returns:
Covariance matrix
- Return type:
np.ndarray
- fvgp.kernels.non_stat_kernel(x1, x2, x0, w, l)[source]#
Non-stationary kernel. kernel = g(x1) g(x2)
- Parameters:
x1 (np.ndarray) – Numpy array of shape (U x D).
x2 (np.ndarray) – Numpy array of shape (V x D).
x0 (np.ndarray) – Numpy array of the basis function locations.
w (np.ndarray) – 1d np.ndarray of weights. len(w) = len(x0).
l (float) – Width measure of the basis functions.
- Returns:
Covariance matrix
- Return type:
np.ndarray
- fvgp.kernels.non_stat_kernel_gradient(x1, x2, x0, w, l)[source]#
Non-stationary kernel gradient. kernel = g(x1) g(x2)
- Parameters:
x1 (np.ndarray) – Numpy array of shape (U x D).
x2 (np.ndarray) – Numpy array of shape (V x D).
x0 (np.ndarray) – Numpy array of the basis function locations.
w (np.ndarray) – 1d np.ndarray of weights. len(w) = len(x0).
l (float) – Width measure of the basis functions.
- Returns:
Covariance matrix
- Return type:
np.ndarray
- fvgp.kernels.get_distance_matrix(x1, x2)[source]#
Function to calculate the pairwise distance matrix of points in x1 and x2.
- Parameters:
x1 (np.ndarray) – Numpy array of shape (U x D).
x2 (np.ndarray) – Numpy array of shape (V x D).
- Returns:
distance matrix
- Return type:
np.ndarray
- fvgp.kernels.get_anisotropic_distance_matrix(x1, x2, hps)[source]#
Function to calculate the pairwise axial-anisotropic distance matrix of points in x1 and x2.
- Parameters:
x1 (np.ndarray) – Numpy array of shape (U x D).
x2 (np.ndarray) – Numpy array of shape (V x D).
hps (np.ndarray) – 1d array of values. The diagonal of the metric tensor describing the axial anisotropy.
- Returns:
distance matrix
- Return type:
np.ndarray
- fvgp.kernels.wendland_anisotropic_gp2Scale_cpu(x1, x2, hps)[source]#
Function for the anisotropic Wendland kernel computed on the CPU. The Wendland kernel is compactly supported, leading to sparse covariance matrices.
- Parameters:
x1 (np.ndarray) – Numpy array of shape (U x D).
x2 (np.ndarray) – Numpy array of shape (V x D).
hps (np.ndarray) – Array of hyperparameters. For this kernel we need D + 1 hyperparameters.
- Returns:
Covariance matrix
- Return type:
np.ndarray
- fvgp.kernels.wendland_anisotropic_gp2Scale_gpu(x1, x2, hps)[source]#
Function for the anisotropic Wendland kernel computed on the GPU. Needs pytorch. The Wendland kernel is compactly supported, leading to sparse covariance matrices.
- Parameters:
x1 (np.ndarray) – Numpy array of shape (U x D).
x2 (np.ndarray) – Numpy array of shape (V x D).
hps (np.ndarray) – Array of hyperparameters. For this kernel we need D + 1 hyperparameters.
- Returns:
Covariance matrix
- Return type:
np.ndarray