Skip to content

Commit

Permalink
added two functions from the DeLange paper about laplacian eigenvalues
Browse files Browse the repository at this point in the history
  • Loading branch information
carlo committed May 9, 2018
1 parent a8290c8 commit b746d9c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kdesmooth.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function y = kdesmooth(lambda,x,sigma)

y=zeros(1,length(x));
for i=1:length(lambda)
y = y + 1/(sqrt(2*pi*sigma.^2)).*exp(-((x-lambda(i))/(sqrt(2)*sigma)).^2);
end
%y = y/sum(y);
20 changes: 20 additions & 0 deletions laplacian_eigenplot.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function laplacian_eigenplot(A)
n=length(A);
% 1. compute the diagonal degree matrix
D = diag(sum(A));
% 2. Compute the normalized Laplacian
L = eye(n) - D^(-1/2)*A*D^(-1/2);

% 3. Compute the eigenvalues lambda
lambda = eig(L);

% 4. Define the grid over which to compute the smoothing
nx = 500;
x = linspace(0,2,nx);

% 5. Draw histogram and the distribution
hold on;
nbins = 200;
histogram(eig(L),nbins,'Normalization','countdensity');
sigma=0.005;
plot(x, kdesmooth(eig(L),x,sigma),'r','LineWidth',2);

0 comments on commit b746d9c

Please sign in to comment.