Skip to content

Instantly share code, notes, and snippets.

@jvlmdr
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvlmdr/74b5f0559603864761fb to your computer and use it in GitHub Desktop.
Save jvlmdr/74b5f0559603864761fb to your computer and use it in GitHub Desktop.
Estimate RIP constant of matrix
n = 100;
m = 50;
A = 1/sqrt(m) * randn(m, n);
K = 10;
trials = 1e4;
rmin = ones(K, 1);
rmax = ones(K, 1);
for k = 1:K
for i = 1:trials
s = randperm(n);
s = s(1:k);
x = zeros(n, 1);
x(s) = randn(k, 1);
r = norm(A*x) / norm(x);
rmin(k) = min(rmin(k), r);
rmax(k) = max(rmax(k), r);
end;
end;
alpha = rmax ./ rmin;
eps = (alpha - 1) ./ (alpha + 1);
bar(1:K, eps);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment