This repository has been archived on 2021-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
NC/mp4/Project_4_Maggioni_Claudio/src/similarityfunc.m

19 lines
454 B
Mathematica
Raw Normal View History

2020-11-04 13:59:14 +00:00
function [S] = similarityfunc(Pts, sigma)
% Create the similarity matrix S from the coordinate list of the input
% points
% dimosthenis.pasadakis@usi.ch
% ICS, USI.
if nargin < 2
% Choose \sigma ~ 2*log(n)
n = length(Pts(:,1));
sigma = log(n);
end
fprintf('----------------------------\n');
fprintf('Gaussian similarity function\n');
fprintf('----------------------------\n');
S = squareform(pdist(Pts));
S = exp(-S.^2 ./ (2*sigma^2));
end