def circular(x, y, sigma):
"""Compute a circular kernel.
The circular kernel is used in geostatic applications. It is an example
of an isotropic stationary kernel and is positive definite in ?^2:
K(x, y) = 2/? arccos(-(||x - y|| / ?)) -
2/? (||x - y|| / ?) sqrt(1 - (||x - y|| / ?)^2)
if ||x - y|| < ?, zero otherwise.
where `x` and `y` are vectors in the input space (i.e., vectors of
features computed from training or test samples), ||x - y|| is the
Euclidean norm, and sigma is a free parameter with no reasonable default.
In other words, `sigma` should be defined *a priori* based on some
geostatistical analysis, such as semi-variogram analysis.
"""
pi2 = 2/PI
norm_sigma = dist.euclidean(x, y) / sigma
return pi2*acos(-norm_sigma) - pi2*norm_sigma*sqrt(1 - norm_sigma**2)
评论列表
文章目录