User:Trettels:Session 21 - 27MAR

From Computational Statistics (CSE383M and CS395T)
Jump to navigation Jump to search

In Class

MATLAB code: (Done with Tameem and Dan )

Currently the ellipse being plotted is much larger than it should be, though the hessian returned from fminunc is the same as returned by the finite difference method shown in lecture.

data=load('volcanodata.txt','-ascii');

x=data(:,1)';
y=data(:,2)';
TT = data(:,3)';
init=[min(TT), max(TT), 50,50,20];
sigma = 30;

tfun = @(t,x,y) (t(1) + (t(2)-t(1))*exp( -( (x-t(3)).^2 + (y - t(4)).^2)./(2*t(5)^2)));


chisqfun = @(theta) sum(sum(((TT-tfun(theta,x,y))./sigma).^2));
[t,~,~,~,~,hessian] =fminunc(chisqfun, init);
fprintf('\nMin Temp: %3.3f, Max Temp: %3.3f,\n x_0: %3.3f, y_0: %3.3f,\n Lambda: %3.3f\n\n',t(1),t(2),t(3),t(4),t(5));
covmat_1=((inv(1/2*hessian)));
covmat_1(3:4,3:4);

n=100;
L = chol(covmat_1(3:4,3:4),'lower');
circle = [cos(2*pi*(0:n)/n); sin(2*pi*(0:n)/n)].*t(5);
ellipse = L*circle + repmat([t(3);t(4)],[1,n+1]);
x = ellipse(1,:);
y = ellipse(2,:);

hold on;
plot(x,y,'r')



Back to TrettelS Index