Demo entry 6720865

1

   

Submitted by anonymous on Mar 19, 2018 at 04:13
Language: ABAP. Code size: 876 Bytes.

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
%% sim = gaussianKernel(x1, x2) returns a gaussian kernel between x1 and x2
%  and returns the value in sim
xny =  x1-x2;
Normxny =xny'*xny;
sim  =  exp(-Normxny/(2*sigma^2));








% =============================================================
    
end

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).