0 | {--
1 | Copyright (C) 2021 Joel Berkeley
3 | This program is free software: you can redistribute it and/or modify
4 | it under the terms of the GNU Affero General Public License as published
5 | by the Free Software Foundation, either version 3 of the License, or
6 | (at your option) any later version.
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU Affero General Public License for more details.
13 | You should have received a copy of the GNU Affero General Public License
14 | along with this program. If not, see <https://www.gnu.org/licenses/>.
15 | --}
16 | ||| Kernel functions, particularly for use in Gaussian processes.
22 | ||| A `Kernel` function maps pairs of points in a feature space to the covariance between those two
23 | ||| points in some target space.
24 | |||
25 | ||| @features The shape of the feature domain.
44 | ||| The radial basis function, or squared exponential kernel. This is a stationary kernel with form
45 | |||
46 | ||| (\mathbf x_i, \mathbf x_j) \mapsto \exp \left(- \frac{r^2}{2l^2} \right)
47 | |||
48 | ||| where `r^2 = (\mathbf x_i - \mathbf x_j)^ \intercal (\mathbf x_i - \mathbf x_j)` and the
49 | ||| length scale `l > 0`.
50 | |||
51 | ||| Two points that are close in feature space will be more tightly correlated than points that
52 | ||| are further apart. The distance over which the correlation reduces is given by the length
53 | ||| scale `l`. Smaller length scales result in faster-varying target values.
54 | |||
55 | ||| @lengthScale The length scale `l`.
56 | export
60 | ||| The Matern kernel for parameter 5/2. This is a stationary kernel with form
61 | |||
62 | ||| (\mathbf x_i, \mathbf x_j) \mapsto \sigma^2 \left(
63 | ||| 1 + \frac{\sqrt{5}r}{l} + \frac{5 r^2}{3 l^2}
64 | ||| \right) \exp \left( -\frac{\sqrt{5}r}{l} \right)
65 | |||
66 | ||| where `r^2 = (\mathbf x_i - \mathbf x_j)^ \intercal (\mathbf x_i - \mathbf x_j)` and the
67 | ||| length scale `l > 0`.
68 | |||
69 | ||| @amplitude The amplitude `\sigma`.
70 | ||| @length_scale The length scale `l`.
71 | export