Skip to content

Commit

Permalink
added sparse coding demo for rvmRegVb
Browse files Browse the repository at this point in the history
  • Loading branch information
sth4nth committed Mar 13, 2016
1 parent e8ccb16 commit aa89335
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions chapter10/demo_rvm.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
% demos for ch07

%% sparse signal recovery demo
clear; close all;

d = 512; % signal length
k = 20; % number of spikes
n = 100; % number of measurements
%
% random +/- 1 signal
x = zeros(d,1);
q = randperm(d);
x(q(1:k)) = sign(randn(k,1));

% projection matrix
A = unitize(randn(d,n),1);
% noisy observations
sigma = 0.005;
e = sigma*randn(1,n);
y = x'*A + e;

[model,llh] = rvmRegVb(A,y);
plot(llh);
m = model.w;

h = max(abs(x))+0.2;
x_range = [1,d];
y_range = [-h,+h];
figure;
subplot(2,1,1);plot(x); axis([x_range,y_range]); title('Original Signal');
subplot(2,1,2);plot(m); axis([x_range,y_range]); title('Recovery Signal');



0 comments on commit aa89335

Please sign in to comment.