From yilin@cs.wisc.edu Wed Jul 24 11:56:46 2002
Date: Wed, 24 Jul 2002 10:58:09 -0500 (CDT)
From: Yi Lin <yilin@cs.wisc.edu>
To: hzhang@cs.wisc.edu

rand('state',100);
n=1000;
d = 200;
noiselevel = 0.6;
x = rand(n,d);
ftrue = 4 * x(:,1) /3 + pi * sin(pi * x(:,3)) + 8 * x(:,6).^5 + 2/(2.71828 - 1) * exp(x(:,8)) - 5;
y = ftrue + randn(n,1) * noiselevel;

K3darray = zeros(n,n,d);
for i = 1:d
K3darray(:,:,i) = newsplinematrix(x(:,i),n);
end

theta = ones(d,1);
Kth = zeros(n,n);
for i = 1:d
Kth = Kth + theta(i) * K3darray(:,:, i);
end

m = 30;
sqrtmse = zeros(1,m);
for j = 1:m
lambda0 = 2^( - j);
bigKth = [Kth + lambda0 * eye(n), ones(n,1); ones(1,n), 0];
cb = bigKth \ [y;0];
fest = [Kth, ones(n,1)] * cb;
sqrtmse(j) = norm(fest - ftrue);
end

[C, bestj] = min(sqrtmse);
lambda0 = 2^( - bestj);

m = 2 * ceil(log2(8 * d));
sqrtmse = zeros(1,m);

warning off;

for iter = 1:m

iter

M = 2^(iter/2 - 2);

newtheta = ones(d,1);
normdiffth = 100000;
while normdiffth > (0.01 * M)

theta = newtheta;

Kth = zeros(n,n);
for inneriter = 1:d
Kth = Kth + theta(inneriter) * K3darray(:,:, inneriter);
end

bigKth = [Kth + lambda0 * eye(n), ones(n,1); ones(1,n), 0];
cb = bigKth \ [y;0];
c = cb(1:n);
b = cb(n+1);

ycb = y - lambda0 * c /2 - b;

G = zeros(n,d);
for inneriter = 1:d
G(:, inneriter) = K3darray(:,:,inneriter) * c;
end

newtheta = lsqlin(G, ycb, ones(1,d), M, [], [], zeros(d,1));

normdiffth = norm(theta - newtheta);
end

fest = [Kth, ones(n,1)] * cb;
sqrtmse(iter) = norm(fest - ftrue);
end

[thesqrtmse, bestiter] = min(sqrtmse);
M = 2^(bestiter/2 - 2);
newtheta = ones(d,1);
normdiffth = 100000;
while normdiffth > (0.01 * M)

theta = newtheta;

Kth = zeros(n,n);
for inneriter = 1:d
Kth = Kth + theta(inneriter) * K3darray(:,:, inneriter);
end

bigKth = [Kth + lambda0 * eye(n), ones(n,1); ones(1,n), 0];
cb = bigKth \ [y;0];
c = cb(1:n);
b = cb(n+1);

ycb = y - lambda0 * c /2 - b;

G = zeros(n,d);
for inneriter = 1:d
G(:, inneriter) = K3darray(:,:,inneriter) * c;
end

newtheta = lsqlin(G, ycb, ones(1,d), M, [], [], zeros(d,1));
normdiffth = norm(theta - newtheta);
end

theta
festcomponents = G * diag(theta);
fest = G * theta + b;

subplot (2,2,1), scatter(x(:,1),festcomponents(:,1))
subplot (2,2,2), scatter(x(:,3),festcomponents(:,3))
subplot (2,2,3), scatter(x(:,6),festcomponents(:,6))
subplot (2,2,4), scatter(x(:,8),festcomponents(:,8))


