-
Notifications
You must be signed in to change notification settings - Fork 3
/
ex_1.m
54 lines (44 loc) · 1.94 KB
/
ex_1.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
EstDimOpts = struct('NumberOfTrials', 15, 'verbose', 0, 'MAXDIM', 100, ...
'MAXAMBDIM', 100, 'Ptwise', false, 'NetsOpts', [], ...
'UseSmoothedS', false, 'EnlargeScales', true);
XName = 'D-Sphere'; XNickName = 'S';
XOpts = struct('NumberOfPoints', 1000, 'Dim', 1, 'EmbedDim', 100, ...
'NoiseType', 'Gaussian', 'NoiseParam', 0.1/sqrt(100));
%% Generate the data set
fprintf('\nGenerating %s data...', XName);
[X,GraphDiffOpts] = GenerateDataSets( XName, XOpts);
X = 1*X;
fprintf('done.');
%% Compute Graph Diffusion, and display diffusion embedding
fprintf('\n\nConstructing graph and diffusion map...\n');
G = GraphDiffusion(X, 0, GraphDiffOpts); % These are for debugging purposes
fprintf('done.\n');
figure;
subplot(1,2,1);plot3(G.EigenVecs(:,2),G.EigenVecs(:,3),G.EigenVecs(:,4),'.');title('Diffusion embedding (2,3,4)');
subplot(1,2,2);plot3(G.EigenVecs(:,5),G.EigenVecs(:,6),G.EigenVecs(:,7),'.');title('Diffusion embedding (5,6,7)');
%% Compute Diffusion Wavelets
Tree = DWPTree (G.T^4, 12, 1e-4, struct('Wavelets',true,'OpThreshold',1e-2,'GSOptions',struct('StopDensity',1,'Threshold',1e-2)));
%% Show some diffusion scaling functions, in regular scale and log10 scale to show exp. decay
figure;
for j = 1:4,
subplot(2,2,j);
scatter3(G.EigenVecs(:,2),G.EigenVecs(:,3),G.EigenVecs(:,4),15,Tree{j,1}.ExtBasis(:,1));hold on;
title(sprintf('Diffusion scaling function at scale %d',j));
end;
figure;
for j = 1:4,
subplot(2,2,j);
scatter3(G.EigenVecs(:,2),G.EigenVecs(:,3),G.EigenVecs(:,4),15,Tree{j,2}.ExtBasis(:,1));hold on;
title(sprintf('Diffusion wavelet at scale %d',j));
end;
% Show some compressed powers of T
figure;
for j = 1:4,
subplot(2,4,j);
imagesc(Tree{j,1}.T{1});title(sprintf('[T]_%d',j));colorbar;
subplot(2,4,j+4);
imagesc(log10(abs(Tree{j,1}.T{1})));title(sprintf('log_{10}(|[T]_%d|)',j));colorbar;
end;
fprintf('\n');
return;
fprintf('\n');