Skip to content

Commit fafc0d2

Browse files
committed
address review comments
1 parent d61c919 commit fafc0d2

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

docs/src/kernels.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ where $h$ is the [Hurst index](https://en.wikipedia.org/wiki/Hurst_exponent#Gene
9393
The [`GaborKernel`](@ref) is defined as
9494

9595
```math
96-
k(x,x'; l,p) =& h(x-x';l,p)\\
97-
h(u;l,p) =& \exp\left(-\cos\left(\pi \sum_i \frac{u_i}{p_i}\right)\sum_i \frac{u_i^2}{l_i^2}\right),
96+
k(x,x'; l,p) = \exp\left(-\cos\left(\pi \sum_i \frac{x_i - x'_i}{p_i}\right)\sum_i \frac{(x_i - x'_i)^2}{l_i^2}\right),
9897
```
9998
where $l_i > 0$ is the lengthscale and $p_i > 0$ is the period.
10099

@@ -154,14 +153,12 @@ where $r$ has the same dimension as $x$ and $r_i > 0$.
154153

155154
## Piecewise Polynomial Kernel
156155

157-
The [`PiecewisePolynomialKernel`](@ref) is defined as
158-
156+
The [`PiecewisePolynomialKernel`](@ref) is defined for $x\in \mathbb{R}^D$ and $V \in \{0,1,2,3\}$ as
159157
```math
160-
k(x,x'; P, V) =& \max(1 - r, 0)^{j + V} f(r, j),\\
161-
r =& x^\top P x',\\
162-
j =& \lfloor \frac{D}{2}\rfloor + V + 1,
158+
k(x,x'; P, V) &= \max(1 - r, 0)^{j + V} f(r, j),
163159
```
164-
where $x\in \mathbb{R}^D$, $V \in \{0,1,2,3\} and $P$ is a positive-definite matrix.
160+
where $r = x^\top P x'$ (with $P$ a positive-definite matrix),
161+
$j = \lfloor \frac{D}{2}\rfloor + V + 1$, and
165162
$f$ is a piecewise polynomial (see source code).
166163

167164
## Polynomial Kernels

docs/src/metrics.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Metrics
22

3-
KernelFunctions.jl relies on [Distances.jl](https://github.com/JuliaStats/Distances.jl) for computing the pairwise matrix.
4-
To do so a distance measure is needed for each kernel. Two very common ones can already be used: `SqEuclidean` and `Euclidean`.
5-
However, not all kernels rely on distance metrics respecting all the definitions as in Distances.jl. For this reason, KernelFunctions.jl provides additional "metrics" such as `DotProduct` ($\langle x, y \rangle$) and `Delta` ($\delta(x,y)$).
3+
`SimpleKernel` implementations rely on [Distances.jl](https://github.com/JuliaStats/Distances.jl) for efficiently computing the pairwise matrix.
4+
This requires a distance measure or metric, such as the commonly used `SqEuclidean` and `Euclidean`.
65

7-
Note that every `SimpleKernel` must have a metric, specified as
6+
The metric used by a given kernel type is specified as
87
```julia
9-
KernelFunctions.metric(::CustomKernel) = SqEuclidean()
8+
KernelFunctions.metric(::CustomKernel) = SqEuclidean()
109
```
1110

11+
However, there are kernels that can be implemented efficiently using "metrics" that do not respect all the definitions expected by Distances.jl. For this reason, KernelFunctions.jl provides additional "metrics" such as `DotProduct` ($\langle x, y \rangle$) and `Delta` ($\delta(x,y)$).
12+
13+
1214
## Adding a new metric
1315

1416
If you want to create a new "metric" just implement the following:

0 commit comments

Comments
 (0)