24小时热门版块排行榜    

Znn3bq.jpeg
汕头大学海洋科学、生物学、生物与医药接受调剂
查看: 783  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 调剂求收留 +30 果然有我 2026-04-10 31/1550 2026-04-13 14:18 by 张zhihao
[教师之家] 转长聘了 +3 简单化xn 2026-04-13 3/150 2026-04-13 14:18 by wwwkkk83
[考研] 化学070300 求调剂 +17 哈哈哈^_^ 2026-04-12 17/850 2026-04-13 08:59 by 紫曦紫棋
[考研] 求调剂,985材料与化工348分 +9 涵竹刘 2026-04-11 13/650 2026-04-12 22:40 by 涵竹刘
[考研] 339求调剂 +8 hanwudada 2026-04-11 9/450 2026-04-12 15:36 by laoshidan
[考研] 电子信息279求调剂,有书读就行 +8 wwwooden 2026-04-08 11/550 2026-04-11 20:22 by cq2548
[考研] 求调剂 +6 电气300求调剂不 2026-04-08 6/300 2026-04-11 20:14 by 逆水乘风
[考研] 11408。358求调剂 +3 TMYzds 2026-04-07 3/150 2026-04-11 17:10 by 氮气气气
[考研] 求调剂 +13 雪逢冬 2026-04-10 13/650 2026-04-11 09:58 by 猪会飞
[考研] 362求调剂 +10 我要考大 2026-04-06 14/700 2026-04-10 17:00 by luoyongfeng
[考研] 一志愿中南大学物理学,英一66,求调剂 +4 长烟旖旎 2026-04-08 5/250 2026-04-10 10:31 by 颖果儿
[考研] 调剂 +19 2261744733 2026-04-08 19/950 2026-04-09 19:11 by vgtyfty
[考研] 283电子信息求调剂 +4 三石WL 2026-04-08 4/200 2026-04-09 10:21 by wp06
[考研] 264求调剂 +11 麦小叮当 2026-04-07 11/550 2026-04-08 16:05 by 一只好果子?
[考研] 一志愿哈工大,初试329,求环境科学与工程调剂! +11 余未辛 2026-04-06 11/550 2026-04-08 15:21 by screening
[考研] 287求调剂 +6 Fnhc 2026-04-07 6/300 2026-04-08 10:05 by xingguangj
[考研] 344求调剂 +11 魏子per 2026-04-07 11/550 2026-04-07 23:01 by JourneyLucky
[考研] 材料调剂 +13 汉123456 2026-04-07 14/700 2026-04-07 22:53 by 来看流星雨10
[考研] 307求调剂 +3 Youth@@ 2026-04-07 3/150 2026-04-07 22:00 by hemengdong
[考研] 325 调剂 +6 QQ小虾 2026-04-07 6/300 2026-04-07 15:17 by Ccclqqq
信息提示
请填处理意见