-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c1c068
commit c796c12
Showing
7 changed files
with
55 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function [ A,b,partition,lambda ] = GenerateRandomGroupLassoDataSet( m,K,density )% density default value should be 100 | ||
|
||
flag=true; | ||
while flag | ||
partition = int32(randi(225, [K 1]));% per Boyd example | ||
n = int32(sum(partition)); % number of features | ||
if (mod(n,16))==0 | ||
flag=false; | ||
end | ||
end | ||
|
||
p = single(density/single(n)); % sparsity density | ||
|
||
% generate block sparse solution vector | ||
x = single(zeros(n,1)); | ||
start_ind = int32(1); | ||
cum_part = int32(cumsum(single(partition))); | ||
|
||
for i = 1:K, | ||
x(start_ind:cum_part(i)) = 0; | ||
if( rand() < p) | ||
% fill nonzeros | ||
x(start_ind:cum_part(i)) = randn(partition(i),1); | ||
end | ||
start_ind = cum_part(i)+1; | ||
end | ||
|
||
% generate random data matrix | ||
A = randn(m,n); | ||
|
||
% normalize columns of A | ||
A = (A*spdiags(1./sqrt(sum(A.^2))',0,double(n),double(n))); | ||
A=full(single(A)); | ||
% generate measurement b with noise | ||
b = single(A*x + sqrt(0.001)*randn(m,1)); | ||
|
||
% lambda max | ||
start_ind = 1; | ||
lambdas=single(zeros(1,K+1)); | ||
for i = 1:K, | ||
sel = start_ind:cum_part(i); | ||
lambdas(i) = norm(A(:,sel)'*b); | ||
start_ind = cum_part(i) + 1; | ||
end | ||
lambda_max = max(lambdas); | ||
|
||
% regularization parameter | ||
lambda = 0.1*lambda_max; | ||
|
||
|
||
end | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.