24小时热门版块排行榜    

查看: 781  |  回复: 0

csumushu

新虫 (初入文坛)

[求助] 为什么ROMP的仿真性能比OMP还弱啊?

function [val,pos] = Regularize(product,Kin)  
%Regularize Summary of this function goes here  
%   Detailed explanation goes here  
%   product = A'*r_n;%传感矩阵A各列与残差的内积  
%   K为稀疏度  
%   pos为选出的各列序号  
%   val为选出的各列与残差的内积值  
%   Reference:Needell D,Vershynin R. Uniform uncertainty principle and  
%   signal recovery via regularized orthogonal matching pursuit.   
%   Foundations of Computational Mathematics, 2009,9(3): 317-334.   
    productabs = abs(product);%取绝对值  
    [productdes,indexproductdes] = sort(productabs,'descend');%降序排列  
    for ii = length(productdes):-1:1  
        if productdes(ii)>1e-6%判断productdes中非零值个数  
            break;  
        end  
    end  
    %Identify:Choose a set J of the K biggest coordinates  
    if ii>=Kin  
        J = indexproductdes(1:Kin);%集合J  
        Jval = productdes(1:Kin);%集合J对应的序列值  
        K = Kin;  
    else%or all of its nonzero coordinates,whichever is smaller  
       J = indexproductdes(1:ii);%集合J  
        Jval = productdes(1:ii);%集合J对应的序列值  
        K = ii;  
    end  
    %Regularize:Among all subsets J0∈J with comparable coordinates  
    MaxE = -1;%循环过程中存储最大能量值  
    for kk = 1:K  
        J0_tmp = zeros(1,K);iJ0 = 1;  
        J0_tmp(iJ0) = J(kk);%以J(kk)为本次寻找J0的基准(最大值)  
        Energy = Jval(kk)^2;%本次寻找J0的能量  
        for mm = kk+1:K  
            if Jval(kk)<2*Jval(mm)%找到符合|u(i)|<=2|u(j)|的  
                iJ0 = iJ0 + 1;%J0自变量增1  
                J0_tmp(iJ0) = J(mm);%更新J0  
                Energy = Energy + Jval(mm)^2;%更新能量  
            else%不符合|u(i)|<=2|u(j)|的  
                break;%跳出本轮寻找,因为后面更小的值也不会符合要求  
            end  
        end  
        if Energy>MaxE%本次所得J0的能量大于前一组  
            J0 = J0_tmp(1:iJ0);%更新J0  
            MaxE = Energy;%更新MaxE,为下次循环做准备  
        end  
    end  
    pos = J0;  
    val = productabs(J0);  
end  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ theta ] = CS_ROMP( y,A,K )  
%CS_ROMP Summary of this function goes here  
%Version: 1.0 written by jbb0523 @2015-04-24  
%   Detailed explanation goes here  
%   y = Phi * x  
%   x = Psi * theta  
%   y = Phi*Psi * theta  
%   令 A = Phi*Psi, 则y=A*theta  
%   现在已知y和A,求theta  
%   Reference:Needell D,Vershynin R.Signal recovery from incomplete and  
%   inaccurate measurements via regularized orthogonal matching pursuit[J].  
%   IEEE Journal on Selected Topics in Signal Processing,2010,4(2):310—316.  
    [y_rows,y_columns] = size(y);  
    if y_rows<y_columns  
        y = y';%y should be a column vector  
    end  
    [M,N] = size(A);%传感矩阵A为M*N矩阵  
    theta = zeros(N,1);%用来存储恢复的theta(列向量)  
    At = zeros(M,3*K);%用来迭代过程中存储A被选择的列  
    Pos_theta = zeros(1,2*K);%用来迭代过程中存储A被选择的列序号  
    Index = 0;  
    r_n = y;%初始化残差(residual)为y  
    %Repeat the following steps K times(or until |I|>=2K)  
    for ii=1:K%迭代K次  
        product = A'*r_n;%传感矩阵A各列与残差的内积  
        %[val,pos] = max(abs(product));%找到最大内积绝对值,即与残差最相关的列  
        [~,pos] = Regularize(product,K);%按正则化规则选择原子  
        At(:,Index+1:Index+length(pos)) = A(:,pos);%存储这几列  
        Pos_theta(Index+1:Index+length(pos)) = pos;%存储这几列的序号  
        if Index+length(pos)<=M%At的行数大于列数,此为最小二乘的基础(列线性无关)  
            Index = Index+length(pos);%更新Index,为下次循环做准备  
        else%At的列数大于行数,列必为线性相关的,At(:,1:Index)'*At(:,1:Index)将不可逆  
            break;%跳出for循环  
        end  
        A(:,pos) = zeros(M,length(pos));%清零A的这几列(其实此行可以不要因为它们与残差正交)  
        %y=At(:,1:Index)*theta,以下求theta的最小二乘解(Least Square)  
        theta_ls = (At(:,1:Index)'*At(:,1:Index))^(-1)*At(:,1:Index)'*y;%最小二乘解  
        %At(:,1:Index)*theta_ls是y在At(:,1:Index)列空间上的正交投影  
        r_n = y - At(:,1:Index)*theta_ls;%更新残差  
        if norm(r_n)<1e-6%Repeat the steps until r=0  
            break;%跳出for循环  
        end  
        if Index>=2*K%or until |I|>=2K  
            break;%跳出for循环  
        end  
    end  
    theta(Pos_theta(1:Index))=theta_ls;%恢复出的theta  
end  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%压缩感知重构算法测试  
clear all;close all;clc;  
M = 128;%观测值个数  
N = 256;%信号x的长度  
K = 12;%信号x的稀疏度  
Index_K = randperm(N);  
x = zeros(N,1);  
x(Index_K(1:K)) = 5*randn(K,1);%x为K稀疏的,且位置是随机的
Psi = eye(N);%x本身是稀疏的,定义稀疏矩阵为单位阵x=Psi*theta  
Phi = randn(M,N);%测量矩阵为高斯矩阵  
A = Phi * Psi;%传感矩阵  
sigma = 0.5;  
e = sigma*randn(M,1);  
y = Phi * x + e;%得到观测向量y   
%% 恢复重构信号x  
tic  
theta = CS_ROMP(y,A,K);  
x_r = Psi * theta;% x=Psi * theta  
toc  
%% 绘图  
figure;  
plot(x_r,'k.-');%绘出x的恢复信号
hold on;  
plot(x,'r');%绘出原信号x  
hold off;  
legend('Recovery','Original')  
fprintf('\n恢复残差:');  
norm(x_r-x)%恢复残差  


以上是ROMP的算法

function [ theta ] = CS_OMP( y,A,t )  
%CS_OMP Summary of this function goes here  
%Version: 1.0 written by jbb0523 @2015-04-18  
%   Detailed explanation goes here  
%   y = Phi * x  
%   x = Psi * theta  
%   y = Phi*Psi * theta  
%   令 A = Phi*Psi, 则y=A*theta  
%   现在已知y和A,求theta  
    [y_rows,y_columns] = size(y);  
    if y_rows<y_columns  
        y = y';%y should be a column vector  
    end  
    [M,N] = size(A);%传感矩阵A为M*N矩阵  
    theta = zeros(N,1);%用来存储恢复的theta(列向量)  
    At = zeros(M,t);%用来迭代过程中存储A被选择的列  
    Pos_theta = zeros(1,t);%用来迭代过程中存储A被选择的列序号  
    r_n = y;%初始化残差(residual)为y  
    for ii=1:t%迭代t次,t为输入参数  
        product = A'*r_n;%传感矩阵A各列与残差的内积  
        [val,pos] = max(abs(product));%找到最大内积绝对值,即与残差最相关的列  
        At(:,ii) = A(:,pos);%存储这一列  
        Pos_theta(ii) = pos;%存储这一列的序号  
        A(:,pos) = zeros(M,1);%清零A的这一列,其实此行可以不要,因为它与残差正交  
        %y=At(:,1:ii)*theta,以下求theta的最小二乘解(Least Square)  
        theta_ls = (At(:,1:ii)'*At(:,1:ii))^(-1)*At(:,1:ii)'*y;%最小二乘解  
        %At(:,1:ii)*theta_ls是y在At(:,1:ii)列空间上的正交投影  
        r_n = y - At(:,1:ii)*theta_ls;%更新残差         
    end  
    theta(Pos_theta)=theta_ls;%恢复出的theta  
end  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%压缩感知重构算法测试  
clear all;close all;clc;  
M = 128;%观测值个数  
N = 256;%信号x的长度  
K = 12;%信号x的稀疏度  
Index_K = randperm(N);  
x = zeros(N,1);
x(Index_K(1:K)) = 5*randn(K,1);%x为K稀疏的,且位置是随机的
Psi = eye(N);%x本身是稀疏的,定义稀疏矩阵为单位阵x=Psi*theta  
Phi = randn(M,N);%测量矩阵为高斯矩阵  
A = Phi * Psi;%传感矩阵  
sigma = 0.5;  
e = sigma*randn(M,1);  
y = Phi * x + e;%得到观测向量y   
%% 恢复重构信号x  
tic  
theta = CS_OMP(y,A,K);  
x_r = Psi * theta;% x=Psi * theta  
toc  
%% 绘图  
figure;  
plot(x_r,'k.-');%绘出x的恢复信号  
hold on;  
plot(x,'r');%绘出原信号x  
hold off;  
legend('Recovery','Original')  
fprintf('\n恢复残差:');  
norm(x_r-x)%恢复残差  
mse(x_r-x)


以上是OMP的算法

算法来自OMPROMP
唯一的改变是在观测值上加了噪声
回复此楼

» 猜你喜欢

Time waits for no one
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 csumushu 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 招08考数学 +5 laoshidan 2026-03-20 12/600 2026-03-23 12:38 by 梨花珞晚风
[考研] 070300化学求调剂 +5 苑豆豆 2026-03-20 5/250 2026-03-23 09:39 by guoliang1816
[考研] 石河子大学(211、双一流)硕博研究生长期招生公告 +3 李子目 2026-03-22 3/150 2026-03-22 21:01 by 怎么释怀
[考研] 一志愿上海交大生物与医药专硕324分,求调剂 +3 jiajunX 2026-03-22 3/150 2026-03-22 19:32 by brblmd
[考研] 08工科 320总分 求调剂 +11 梨花珞晚风 2026-03-17 11/550 2026-03-22 17:42 by luoyongfeng
[考研] 289求调剂 +7 怀瑾握瑜l 2026-03-20 7/350 2026-03-22 15:57 by ColorlessPI
[考研] 生物学调剂 +5 Surekei 2026-03-21 5/250 2026-03-22 14:39 by tcx007
[考研] 求调剂 +7 Auroracx 2026-03-22 7/350 2026-03-22 12:38 by 素颜倾城1988
[考研] 354求调剂 +7 Tyoumou 2026-03-18 10/500 2026-03-22 11:11 by 人来盛
[考研] 一志愿东华大学控制学硕320求调剂 +3 Grand777 2026-03-21 3/150 2026-03-21 19:23 by 简之-
[考研] 求调剂 +3 .m.. 2026-03-21 4/200 2026-03-21 16:25 by barlinike
[考研] 279分求调剂 一志愿211 +14 chaojifeixia 2026-03-19 15/750 2026-03-21 13:24 by zhukairuo
[考研] 299求调剂 +6 △小透明* 2026-03-17 6/300 2026-03-21 02:42 by JourneyLucky
[考研] 一志愿中国石油大学(华东) 本科齐鲁工业大学 +3 石能伟 2026-03-17 3/150 2026-03-21 02:22 by JourneyLucky
[考研] 085700资源与环境308求调剂 +12 墨墨漠 2026-03-18 13/650 2026-03-21 01:42 by JourneyLucky
[考研] 华东师范大学-071000生物学-293分-求调剂 +3 研究生何瑶明 2026-03-18 3/150 2026-03-21 01:30 by JourneyLucky
[考研] 22408 344分 求调剂 一志愿 华电计算机技术 +4 solanXXX 2026-03-20 4/200 2026-03-20 23:49 by alg094825
[考研] 0703化学调剂 +4 18889395102 2026-03-18 4/200 2026-03-19 16:13 by 30660438
[考研] 085601材料工程专硕求调剂 +10 慕寒mio 2026-03-16 10/500 2026-03-19 15:26 by 丁丁*
[考研] 材料与化工求调剂 +7 为学666 2026-03-16 7/350 2026-03-19 14:48 by 尽舜尧1
信息提示
请填处理意见