OMP算法 ( smit正交化)
也就是正交的MP算法。
MP算法的次最优性来源其残差只与当前投影方向垂直,这样在接下来的投影中,很有可能会再次投影到原来的方向。
于是,在投影时,如果我们使得残差Rk+1与x1-xk+1的所有向量垂直,则可以克服这个问题,如下:
求解方法
假设我们已经得到了第k步的最优解:
我们要继续更新到第k+1步,目标是得到:
需要注意的是,我们下一步更新时,之前原子的系数 也要更新,否则不能满足约束。
于是我们需要求得如何更新之前原子系数 ,以及如何求得下一个投影方向 。
收敛性:
同样根据勾股定理,得到如下:
于是算法收敛。
具体步骤:
function [A]=OMP(D,X,L);
%=============================================
% Sparse coding of a group of signals based on a given
% dictionary and specified number of atoms to use.
% input arguments: D - the dictionary
% X - the signals to represent
% L - the maximal number of coefficient for representation
% of each signal.
% output arguments: A - sparse coefficient matrix.
%=============================================
[n,P]=size(X);
[n,K]=size(D);
for k=1:1:P,
a=[];
x=X(:,k);
residual=x;
indx=zeros(L,1);
for j=1:1:L,
proj=D'*residual;
pos=find(abs(proj)==max(abs(proj)));
pos=pos(1);
indx(j)=pos;
a=pinv(D(:,indx(1:j)))*x;
residual=x-D(:,indx(1:j))*a;
end;
temp=zeros(K,1);
temp(indx)=a;
A(:,k)=sparse(temp);
end;
return;