load  T4-1.DAT
load  T4-5.DAT

figure

X_close=T4_1;
X_open=T4_5;

n=length(X_close);

X_ALL=[X_close X_open];

lambda=-1:0.01:1.5;

m=length(lambda);

L_lambda=zeros(m,1);

for i=1:m
    if lambda(i)==0
        X_lambda=log(X_close);
    else 
        X_lambda=(X_close.^lambda(i)-1)/lambda(i);
    end
    L_lambda(i)=-n/2*log(1/n*(sum((X_lambda-mean(X_lambda)).^2)))+(lambda(i)-1)*sum(log(X_close));
end 

plot(lambda(101:150),L_lambda(101:150));
title('Plot of l(\lambda) versus \lambda for radiation data (door closed).')
xlabel('\lambda')
ylabel('l(\lambda)')

Lambda=0.25;
X_close_l=(X_close.^Lambda-1)/Lambda;

figure
subplot(2,1,1)
qqplot(X_close)
title('Q-Q plot of the original Radiation Data (Door Close)')
subplot(2,1,2)
qqplot(X_close_l);
title('Q-Q plot of the transformed Radiation Data (Door Close)')

Lambda=0.25;
X_open_l=(X_open.^Lambda-1)/Lambda;

figure
subplot(2,1,1)
qqplot(X_open)
title('Q-Q plot of the original Radiation Data (Door Open)')

subplot(2,1,2)
qqplot(X_open_l);
title('Q-Q plot of the transformed Radiation Data (Door Open)')


Lambda2=0.005:0.005:0.5;
l2=zeros(100,100);
for i=1:100
    for j=1:100 
          X_lambda_close=(X_close.^Lambda2(i)-1)/Lambda2(i);
          X_lambda_open=(X_open.^Lambda2(j)-1)/Lambda2(j);
          X_lambda2=[X_lambda_close X_lambda_open];
          S_lambda=cov(X_lambda2);
          
          l2(i,j)=-n/2*log(det(S_lambda))+(Lambda2(i)-1)*sum(log(X_close))+(Lambda2(j)-1)*sum(log(X_open));
    end
end 

figure
v=linspace(219,225.5,9);
v(10)=225.9;
contour(Lambda2, Lambda2, l2,v);
title('Contour plot of l(\lambda_1,\lambda_2) for the radation data');
xlabel('\lambda_1');
ylabel('\lambda_2');


          
          
        
        
