首页 > 代码库 > 压缩感知中常用的观测矩阵

压缩感知中常用的观测矩阵

接上文:《压缩感知中常用的待还原信号种类》,http://blog.csdn.net/zhyoulun/article/details/25600311

在压缩感知中,观测矩阵就是指y=Ax中的A。A是一个n*m的矩阵,矩阵中的每一个元素独立同分布于一个特定的分布。分布的种类如下:
1、USE。一致球集合,Uniform spherical ensemble,首先计算出一个n*m的矩阵,矩阵中的每一个元素服从标准正态分布,然后对这个矩阵的每一列做归一化。
2、RSE。随机信号集合,Random signs ensemble,首先计算出一个n*m的矩阵,矩阵中的每一个元素服从伯努利+/-1分布,然后对这个矩阵的每一列做归一化。
3、Fourier。局部傅里叶集合,Partial Fourier ensemble,Matrices in this ensemble are generated by taking the m by m Fourier matrix, sampling n rows at random, and scaling columns to have unit euclidean length.
4、RST。Partial RST (Real Fourier) ensemble. See ‘Fourier‘ above.
5、Hadamard。Partial Hadamard ensemble. Matrices in this ensemble are generated by taking the m by m Hadamard matrix, sampling n rows at random, and scaling columns to have unit euclidean length.
6、URP。Uniform Random Projection ensemble. Matrices in this ensemble are generated by sampling n rows of an m by m random orthogonal matrix.
7、IR。Identity and Random otho-basis. An n by 2n matrix is constructed, as the concatenation of the n by n identity and an n x n random ortho-basis. 


SparseLab2.1-Core\Utilities\BuildDatasets\MatrixEnsemble.m
附代码
function Phi = MatrixEnsemble(n,m,ensemble)
% MatrixEnsemble: Generates a random matrix of size n by m.
%
% Usage:
% Phi = MatrixEnsemble(n,m,ensemble)
% Inputs:
% n number of rows
% m number of columns
% ensemble string containing name of matrix ensemble:
% ‘USE‘, ‘RSE‘, ‘Fourier‘, ‘RST‘, ‘Hadamard‘, ‘URP‘, ‘IR‘. 
% Default is ‘USE‘.
% Outputs:
% Phi n by m matrix from the specified ensemble
% Description:
% This function creates a matrix from the specified random matrix 
% ensemble. The following random ensembles are implemented:
%
% ‘USE‘ - Uniform spherical ensemble. Columns are n-vectors, 
% uniformly distributed on the sphere S^{n-1} (default).
%
% ‘RSE‘ - Random signs ensemble. Entries in the matrix are 
% chosen from a bernoulli +/-1 distribution, and columns are 
% normalized to have unit euclidean length.
%
% ‘Fourier‘ - Partial Fourier ensemble. Matrices in this ensemble 
% are generated by taking the m by m Fourier matrix, sampling 
% n rows at random, and scaling columns to have unit euclidean length.
%
% ‘RST‘ - Partial RST (Real Fourier) ensemble. See ‘Fourier‘ above.
%
% ‘Hadamard‘ - Partial Hadamard ensemble. Matrices in this ensemble 
% are generated by taking the m by m Hadamard matrix, sampling 
% n rows at random, and scaling columns to have unit euclidean length.
%
% ‘URP‘ - Uniform Random Projection ensemble. Matrices in this 
% ensemble are generated by sampling n rows of an m by m 
% random orthogonal matrix.
%
% ‘IR‘ - Identity and Random otho-basis. An n by 2n matrix is 
% constructed, as the concatenation of the n by n identity and 
% an n x n random ortho-basis. 
%
% See Also
% SparseVector

if nargin < 3,
    ensemble = ‘USE‘;
end

switch upper(ensemble)
    case ‘USE‘
        Phi = randn(n,m);

        % Normalize the columns of Phi
        for j = 1:m
            Phi(:,j) = Phi(:,j) ./ twonorm(Phi(:,j));
        end
        
    case ‘RSE‘
        Phi = sign(rand([n m]) - 0.5);
        zz = find(Phi == 0);
        Phi(zz) = ones(size(zz));

        % Normalize the columns of Phi
        for ii = 1:size(Phi,2)
            Phi(:,ii) = Phi(:,ii) ./ twonorm(Phi(:,ii));
        end
        
    case ‘HADAMARD‘
        H = hadamard(m);
        p = randperm(m);
        Phi = H(p(1:n), :);
    
        % Normalize the columns of Phi
        for ii = 1:size(Phi,2)
            Phi(:,ii) = Phi(:,ii) ./ twonorm(Phi(:,ii));
        end
        
    case ‘FOURIER‘
        H = FourierMat(m);
        p = randperm(m);
        Phi = H(p(1:n), :);
    
        % Normalize the columns of Phi
        for ii = 1:size(Phi,2)
            Phi(:,ii) = Phi(:,ii) ./ twonorm(Phi(:,ii));
        end

    case ‘RST‘
        H = RSTMat(m);
        p = randperm(m);
        Phi = H(p(1:n), :);
    
        % Normalize the columns of Phi
        for ii = 1:size(Phi,2)
            Phi(:,ii) = Phi(:,ii) ./ twonorm(Phi(:,ii));
        end

    case ‘URP‘
        [U,S,V] = svd(rand(n,m),‘econ‘);
        Phi = V‘;

        % Normalize the columns of Phi
        for ii = 1:size(Phi,2)
            Phi(:,ii) = Phi(:,ii) ./ twonorm(Phi(:,ii));
        end
        
    case ‘IR‘
        [Q,R] = qr(rand(n));
        Phi = [eye(n) Q];
        
end%
% Part of SparseLab Version:100
% Created Tuesday March 28, 2006
% This is Copyrighted Material
% For Copying permissions see COPYING.m
% Comments? e-mail sparselab@stanford.edu
%

运行示例: