From: Steve on
Hello,
I'm trying to visualize the spread of a function(x,y) minima, caused by modeled measurement uncertainties, and how it changes by increasing the number of measurements.

That's what i did so far:

- generating a grid xy
- evaluate a test function z=f(x,y) and add error term
- perform fit to obtain function minima
- compute cov(xmin,ymin)
- plot the variances and covariances

I have two questions:

1. I'm observing that the variances in x and y direction are significantly different. Not sure where I got something wrong?

2. Would you suggest a better way of quantifying the spread of the location of the minima. I'm not worried about the exact shape of the spread.

Best Regards,
PS.: FYI: this is not part of any homework assignment.
Steve




clear all
close all
clc

a=-0.02; %min error limit
b=0.02; %max error limit

mink=5; %min grid size
inck=5; %grid increment
maxk=15; %max grid size


index=1; %index used for saving cov


for k=mink:inck:maxk

[x,y]=meshgrid(linspace(-5,5,k));

for i=1:100
%rand('state',sum(clock));
z0 = a + (b-a).*rand(size(x));

z=5.*(x.^2+y.^2).*(1+z0);


M=[x(:).^2 (-2.*x(:)) y(:).^2 (-2.*y(:)) ones(size(x(:)))];

sol = pinv(M)*z(:);

zrec=sol(1).*x.^2 -2.*sol(2).*x + sol(3).*y.^2 -2.*sol(4).*y +sol(5).*ones(size(x));


figure(k)
plot(sol(2),sol(4),'o')
hold on

data(i,1)=sol(1);
data(i,2)=sol(2);

end

axis equal
hold off

temp=cov(data(:,1),data(:,2));
covdata11(index)=temp(1,1);
covdata12(index)=temp(1,2);
covdata21(index)=temp(2,1);
covdata22(index)=temp(2,2);

index=index+1;
end


ki=mink:inck:maxk

figure(1)
plot(ki,covdata11,'o')
hold on
plot(ki,covdata12,'x')
hold on
plot(ki,covdata21,'*')
hold on
plot(ki,covdata22,'v')