1
0
Fork 0
This repository has been archived on 2019-12-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coursera-ml-007-exercises/ex6/gaussianKernel.m

24 lines
705 B
Mathematica
Raw Normal View History

2014-11-10 23:44:39 +01:00
function sim = gaussianKernel(x1, x2, sigma)
%RBFKERNEL returns a radial basis function kernel between x1 and x2
% sim = gaussianKernel(x1, x2) returns a gaussian kernel between x1 and x2
% and returns the value in sim
% Ensure that x1 and x2 are column vectors
x1 = x1(:); x2 = x2(:);
% You need to return the following variables correctly.
sim = 0;
% ====================== YOUR CODE HERE ======================
% Instructions: Fill in this function to return the similarity between x1
% and x2 computed using a Gaussian kernel with bandwidth
% sigma
%
%
2014-11-13 22:59:48 +01:00
sim = exp(-dot(x2-x1,x2-x1)/(2*sigma^2));
2014-11-10 23:44:39 +01:00
% =============================================================
2014-11-13 22:59:48 +01:00
2014-11-10 23:44:39 +01:00
end