Skip to content

Commit 4109fe8

Browse files
committed
Use exponentiation as kappa function
1 parent 7da660a commit 4109fe8

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/kernels/maha.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
"""
2-
MahaKernel(P::AbstractMatrix, kappa::Function)
2+
MahalanobisKernel(P::AbstractMatrix, kappa::Function)
33
44
Mahalanobis distance-based kernel given by
55
```math
6-
κ(x,y) = kappa(r^2), r^2 = maha(x,P,y) = (x-y)'*inv(P)*(x-y)
6+
κ(x,y) = exp(-r^2), r^2 = maha(x,P,y) = (x-y)'*inv(P)*(x-y)
77
```
8-
where the matrix P is the metric and kappa is a user defined kernel function.
8+
where the matrix P is the metric.
99
1010
"""
11-
struct MahaKernel{T<:Real} <: BaseKernel
12-
P::AbstractMatrix{T}
13-
kappa::Function
14-
function MahaKernel(P::AbstractMatrix{T}, kappa::Function) where {T<:Real}
11+
struct MahalanobisKernel{T<:Real,A<:AbstractMatrix{T}} <: BaseKernel
12+
P::A
13+
function MahalanobisKernel(P::AbstractMatrix{T}) where {T<:Real}
1514
LinearAlgebra.checksquare(P)
16-
new{T}(P, kappa)
15+
new{T}(P)
1716
end
1817
end
1918

20-
kappa::MahaKernel, d::T) where {T<:Real} = κ.kappa(d)
19+
kappa::MahalanobisKernel, d::T) where {T<:Real} = exp(-d)
2120

22-
metric::MahaKernel) = SqMahalanobis.P)
21+
metric::MahalanobisKernel) = SqMahalanobis.P)

0 commit comments

Comments
 (0)