udisomapgeodistancek.m
来自「提供了一种维数约减的思路」· M 代码 · 共 40 行
M
40 行
function [GeoD,D]=udIsomapGeoDistanceK(X, NeighborsNum);
% 计算Isomap算法的测地线距离
% Input:
% X = D x N matrix of input points (where D is the dimensionality of points, N is the number of data points)
% NeighborsNum = neighborhood size
%
% Output:
% GeoD = Geodesic Distance
%%%%% Step 0: Initialization and Parameters %%%%%
D = L2_distance(X, X, 1);
N = size(D,1);
if ~(N==size(D,2))
error('D must be a square matrix');
end;
K = NeighborsNum;
INF = 1000*max(max(D))*N; %% effectively infinite distance
%%%%% Step 1: Construct neighborhood graph %%%%%
%disp('Constructing neighborhood graph...');
[tmp, ind] = sort(D);
tic;
for i=1:N
D(i,ind((2+K):end,i)) = INF;
end
D = sparse(D);
D = min(D,D'); %% Make sure distance matrix is symmetric
%%%% Step 2: Compute shortest paths %%%%%
landmarks = 1:N;
GeoD = dijkstra(sparse(D), landmarks);
return;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?