LLE算法代码
% LLE ALGORITHM (using K nearest neighbors)
%
% [Y] = lle(X,K,dmax)
%
% X = data as D x N matrix (D = dimensionality, N = #points)
%(D = 点的维数, N = 点数)
% K = number of neighbors(领域点的个数)
% dmax = max embedding dimensionality(最大嵌入维数)
% Y = embedding as dmax x N matrix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%
function [Y] = lle(X,K,d)
[D,N] = size(X);
%D是矩阵的行数,N是矩阵的列数
fprintf(1,'LLE running on %d points in %d dimensions\n',N,D);
% STEP1: COMPUTE PAIRWISE DISTANCES & FIND NEIGHBORS %寻找邻居数据点
fprintf(1,'-->Finding %d nearest neighbours.\n',K);
X2 = sum(X.^2,1);
%矩阵X中的每个元素以2为指数求幂值,并且竖向相加
%if two point X=(x1,x2),Y=(y1,y2)
%than the distance between X and Y is sqtr((x1-y1) .^2+ (x2-y2).^2) distance = repmat(X2,N,1)+repmat(X2',1,N)-2*X'*X;
%repmat就是在行方向把X2复制成N份,列方向为1份