-
Notifications
You must be signed in to change notification settings - Fork 40
Adding Gibbskernel #374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Gibbskernel #374
Changes from 17 commits
d50f2b4
2ca62f4
2b83286
e4d1414
f9f066a
d6b53b9
698c453
3a98028
0f757a3
2e1df2d
b5c6faa
19e6665
21de7d4
4ddafbe
9fd1d14
5531851
78faeac
ae8b3d4
6b91a23
a914957
6eb4099
79aa4f5
0942447
de3e535
0caf2fd
cfbca3d
1fb7903
f577700
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||||
""" | ||||||
GibbsKernel(x, y) | ||||||
|
||||||
# Definition | ||||||
|
||||||
The Gibbs kernel is non-stationary generalisation of the Squared-Exponential | ||||||
devmotion marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
kernel. The lengthscale parameter ``l`` becomes a function of | ||||||
position ``l(x)``. | ||||||
|
||||||
``l(x) = l`` then you recover the standard Squared-Exponential kernel | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great thanks and that answers my other question about the square root / squaring about with_lengthscale There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lengthscale is just |
||||||
with constant lengthscale ``l``. | ||||||
|
||||||
```math | ||||||
k(x, y) = \\sqrt{ \\left(\\frac{2 l(x) l(y)}{l(x)^2 + l(y)^2} \\right) } | ||||||
devmotion marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
\\quad \\rm{exp} \\left( - \\frac{(x - y)^2}{l(x)^2 + l(y)^2} \\right) | ||||||
``` | ||||||
|
||||||
devmotion marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
[1] - Mark N. Gibbs. "Bayesian Gaussian Processes for Regression and Classication." | ||||||
PhD thesis, 1997 | ||||||
|
||||||
[2] - Christopher J. Paciorek and Mark J. Schervish. "Nonstationary Covariance | ||||||
Functions for Gaussian Process Regression". NEURIPS, 2003 | ||||||
|
||||||
[3] - Sami Remes, Markus Heinonen, Samuel Kaski. | ||||||
"Non-Stationary Spectral Kernels". arXiV:1705.08736, 2017 | ||||||
|
||||||
[4] - Sami Remes, Markus Heinonen, Samuel Kaski. | ||||||
"Neural Non-Stationary Spectral Kernel". arXiv:1811.10978, 2018 | ||||||
devmotion marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
""" | ||||||
struct GibbsKernel{T} <: Kernel | ||||||
lengthscale::T | ||||||
end | ||||||
|
||||||
GibbsKernel(; lengthscale) = GibbsKernel(lengthscale) | ||||||
|
||||||
function (k::GibbsKernel)(x, y) | ||||||
lengthscale = k.lengthscale | ||||||
lx = lengthscale(x) | ||||||
ly = lengthscale(y) | ||||||
l = invsqrt2 * hypot(lx, ly) | ||||||
kernel = (sqrt(lx * ly) / l) * with_lengthscale(SqExponentialKernel(), l) | ||||||
return kernel(x, y) | ||||||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@testset "gibbskernel" begin | ||
x = randn() | ||
y = randn() | ||
|
||
# this is the gibbs lengthscale function. | ||
ell(x) = exp(sum(sin, x)) | ||
# create a gibbs kernel with our specific lengthscale function | ||
k_gibbs = GibbsKernel(ell) | ||
|
||
@test k_gibbs(x, y) ≈ sqrt((2 * ell(x) * ell(y)) / (ell(x)^2 + ell(y)^2)) * exp(- norm(x - y)^2 / (ell(x)^2 + ell(y)^2)) | ||
Cyberface marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
end | ||
devmotion marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.