Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GapSpectral
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
GapSpectral
Commits
7fb11a38
Commit
7fb11a38
authored
Sep 21, 2018
by
Andrew Cohen
Browse files
Options
Downloads
Patches
Plain Diff
gap breaks on first local maxima
parent
e5d6b410
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
GapSpectral.m
+21
-8
21 additions, 8 deletions
GapSpectral.m
with
21 additions
and
8 deletions
GapSpectral.m
+
21
−
8
View file @
7fb11a38
...
@@ -52,6 +52,11 @@
...
@@ -52,6 +52,11 @@
function
[
kGap
Gap
S
idx
]
=
GapSpectral
(
DistanceMatrix
,
nMaxClusters
,
bAlgorithmicInformationDistance
)
function
[
kGap
Gap
S
idx
]
=
GapSpectral
(
DistanceMatrix
,
nMaxClusters
,
bAlgorithmicInformationDistance
)
kGap
=-
1
;
Gap
=
[];
S
=
[];
idx
=
[];
if
nargin
<
3
if
nargin
<
3
bAlgorithmicInformationDistance
=
1
;
bAlgorithmicInformationDistance
=
1
;
end
end
...
@@ -99,17 +104,25 @@ for k=1:nMaxClusters
...
@@ -99,17 +104,25 @@ for k=1:nMaxClusters
S
(
k
)
=
sdk
*
sqrt
(
1
+
1
/
B
);
S
(
k
)
=
sdk
*
sqrt
(
1
+
1
/
B
);
% Gap
% Gap
% S
% S
if
k
>
1
if
Gap
(
k
-
1
)
>=
Gap
(
k
)
-
S
(
k
)
% found it!
kGap
=
k
-
1
;
break
;
end
end
end
end
figure
if
kGap
<
0
errorbar
(
[
1
:
nMaxClusters
],
Gap
,
S
)
% rut roh!
set
(
gca
,
'XTick'
,[
1
:
nMaxClusters
])
fprintf
(
2
,
'error - gap did not converge?\n'
)
k
=
1
;
while
((
k
<
nMaxClusters
)
&&
(
Gap
(
k
)
<
Gap
(
k
+
1
)
-
S
(
k
+
1
)))
k
=
k
+
1
;
end
end
kGap
=
k
;
%
% figure
% errorbar( [1:length(Gap)],Gap,S)
% set(gca,'XTick',[1:length(Gap)])
if
(
kGap
>
1
)
if
(
kGap
>
1
)
idx
=
SpectralCluster
(
D
,
kGap
);
idx
=
SpectralCluster
(
D
,
kGap
);
else
else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment