sf.apps.points.rbf_kernel

rbf_kernel(R, sigma)[source]

Calculate the RBF kernel matrix from a set of input points.

The kernel parameter \(\sigma\) is used to define the kernel scale. Points that are much further than \(\sigma\) from each other lead to small entries of the kernel matrix, whereas points much closer than \(\sigma\) generate large entries.

The Euclidean norm is used to measure distance in this function, resulting in a positive-semidefinite kernel.

Example usage:

>>> R = np.array([[0, 1], [1, 0], [0, 0], [1, 1]])
>>> rbf_kernel (R, 1.0)
array([[1., 0.36787944, 0.60653066, 0.60653066],
       [0.36787944, 1., 0.60653066, 0.60653066],
       [0.60653066, 0.60653066, 1., 0.36787944],
       [0.60653066, 0.60653066, 0.36787944, 1.,]])
Parameters
  • R (array) – Coordinate matrix. Rows of this array are the coordinates of the points.

  • sigma (float) – kernel parameter

Returns

the RBF kernel matrix

Return type

K (array)