RBF Kernel
MediumMachine LearningMath
Description
Given two equal-length vectors and a gamma parameter, return the radial basis function kernel value exp(-gamma * squared Euclidean distance). Round the result to 4 decimal places.
Examples
Input:
[0,0], [0,0], 1Output:
1Explanation:
The kernel decays from one toward zero as the squared distance between the two points grows, controlled by gamma.
Input:
[0,0], [1,0], 1Output:
0.3679Explanation:
The kernel decays from one toward zero as the squared distance between the two points grows, controlled by gamma.
Input:
[1,2], [3,4], 0.5Output:
0.0183Explanation:
The kernel decays from one toward zero as the squared distance between the two points grows, controlled by gamma.
Constraints
- •
1 ≤ length ≤ 10⁴ - •
gamma > 0