view gaussianKernel.m @ 3:ace890ed0ed9 default tip

Use lookup to look for all words at once
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Sat, 10 Dec 2011 15:56:02 -0500
parents e0f1290d2b43
children
line wrap: on
line source

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(:);

  sim = exp ( -sumsq (x1-x2)/(2*sigma^2));
endfunction