-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
with_lengthscale(kernel::Kernel, lengthscale::Real) | ||
with_lengthscale(kernel::Kernel, lengthscales::AbstractVector{<:Real}) | ||
Construct a transformed kernel with `lengthscale`. | ||
If a vector `lengthscales` is passed instead, construct an "ARD" kernel with different lengthscales for each dimension. | ||
The following two ways of constructing a squared-exponential kernel with | ||
a given lengthscale are equivalent: | ||
```jldoctest | ||
julia> ℓ = 2.5; | ||
julia> isequal(SqExponentialKernel() ∘ ScaleTransform(inv(ℓ)), with_lengthscale(SqExponentialKernel(), ℓ)) | ||
true | ||
``` | ||
and for the ARD case: | ||
```jldoctest | ||
julia> ℓ = [0.5, 2.5]; | ||
julia> isequal(SqExponentialKernel() ∘ ARDTransform(inv.(ℓ)), with_lengthscale(SqExponentialKernel(), ℓ)) | ||
true | ||
``` | ||
""" | ||
function with_lengthscale(kernel::Kernel, lengthscale::Real) | ||
return compose(kernel, ScaleTransform(inv(lengthscale))) | ||
end | ||
function with_lengthscale(kernel::Kernel, lengthscales::AbstractVector{<:Real}) | ||
return compose(kernel, ARDTransform(map(inv, lengthscales))) | ||
end |