cofi.utils.SquaredExponentialKernel#
- class cofi.utils.SquaredExponentialKernel(positions, nugget=1e-10)[source]#
Squared exponential (Gaussian/RBF) correlation kernel.
Computes the kernel matrix and its first and second derivatives with respect to \(\eta = \log \ell\), where \(\ell\) is the correlation length.
\[K(\eta)_{ij} = \exp\!\Big(-\frac{d_{ij}^2}{2\ell^2}\Big) + \nu\,\delta_{ij}\]where \(\ell = e^\eta\), \(d_{ij} = |x_i - x_j|\), and \(\nu\) is a small nugget for numerical stability.
- Parameters:
positions (array_like) – 1-D array of data point positions (e.g. time samples). Shape
(n_data,).nugget (float, optional) – Small diagonal addition for positive-definiteness. Default
1e-10.
- n_params#
Number of kernel hyperparameters (always 1 for this kernel).
- Type:
int
- n_data#
Number of data points.
- Type:
int
- D2#
Precomputed squared-distance matrix, shape
(n_data, n_data).- Type:
np.ndarray
Reference Details
- derivative(eta)[source]#
First derivative \(\partial K / \partial \eta\).
\[\frac{\partial K_{ij}}{\partial\eta} = 2\,U_{ij}\,K^0_{ij}\]where \(U_{ij} = d_{ij}^2/(2\ell^2)\) and \(K^0_{ij} = e^{-U_{ij}}\) (without nugget).
- Parameters:
eta (float)
- Returns:
K_eta
- Return type:
np.ndarray, shape (n_data, n_data)
- evaluate(eta)[source]#
Kernel matrix \(K(\eta)\).
- Parameters:
eta (float) – Log-correlation-length, \(\eta = \log \ell\).
- Returns:
K
- Return type:
np.ndarray, shape (n_data, n_data)
- second_derivative(eta)[source]#
Second derivative \(\partial^2 K / \partial \eta^2\).
\[\frac{\partial^2 K_{ij}}{\partial\eta^2} = 4\,U_{ij}\,(U_{ij} - 1)\,K^0_{ij}\]- Parameters:
eta (float)
- Returns:
K_etaeta
- Return type:
np.ndarray, shape (n_data, n_data)
- n_params = 1#