www.pudn.com > tfarma10.rar > plot_fit.m, change:2004-09-18,size:25750b


function plot_fit(exp, fig, style, test, sub)
% function plot_fit(exp, fig, style, test, sub)
%   This file is part of the TFPM toolbox v1.0 (c)
%   michael.jachan@tuwien.ac.at and underlies the GPL.
% 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if(0)% TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;tfpm;
exp= 'ord2A';
fig= 99;
style= '-';
test= 0;
sub= 1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end;% TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

re_im= 'i';
mo_no= 'n';
alpha= 1/2;
beta = 1/2;
rho= 1-log(12);
%rho=0;

M= 2;
L= 2;
MSEn= [];
meanMn= [];
meanLn= [];
for n= 6:9
   N= 2^n;
   resultname= sprintf('data/%04d/%s%d%d%s%s.mat', N, exp, M, L, re_im, mo_no);
   load(resultname)
   sprintf('%s%4d', resultname, MM)
   switch(exp(end))
    case 'A'
     Ns= (2:(1+Mmax))'*(2*(0:Lmax)+1)-1;
    case 'B'
     Ns= (2:(1+Mmax))'*(2*(0:Lmax)+1)-1;
    case 'C'
     Ns= (2*(1:Mmax))'*(2*(0:Lmax)+1)-1;
   end;

if(sub)
   ee     = min(log(EE)     , [], 3);
   eeprime= min(log(EEprime), [], 3);
else
   ee     = log(EE(:, :, 1, :));
   eeprime= log(EEprime(:, :, 1, :));
end;

   MDLhist= zeros(Mmax, Lmax+1);
   BIChist= zeros(Mmax, Lmax+1);
   AIChist= zeros(Mmax, Lmax+1);
   GIChist= zeros(Mmax, Lmax+1);
   MIChist= zeros(Mmax, Lmax+1);
   mdlhist= zeros(Mmax, Lmax+1);
   bichist= zeros(Mmax, Lmax+1);
   aichist= zeros(Mmax, Lmax+1);
   gichist= zeros(Mmax, Lmax+1);
   michist= zeros(Mmax, Lmax+1);
   
   for mm= 1:MM
      e= ee(:, :, 1, mm);
      eprime= eeprime(:, :, 1, mm);
      MDL= eprime + (log(N+1)+rho)  *(Ns+1/2)/N;
      BIC= eprime + log(N)          *(Ns    )/N;
      AIC= eprime + 2               *(Ns    )/N;
      GIC= eprime + (2+rho)         *(Ns    )/N;
      MIC= eprime + (1+rho+log(N)/2)*(Ns    )/N;
      mdl= e + (log(N+1)+rho)  *(Ns+1/2)/N;
      bic= e + log(N)          *(Ns    )/N;
      aic= e + 2               *(Ns    )/N;
      gic= e + (2+rho)         *(Ns    )/N;
      mic= e + (1+rho+log(N)/2)*(Ns    )/N;

      [MMDL, LMDL] = find(MDL==min(min(MDL)));LMDL= LMDL-1;
      [MBIC, LBIC] = find(BIC==min(min(BIC)));LBIC= LBIC-1;
      [MAIC, LAIC] = find(AIC==min(min(AIC)));LAIC= LAIC-1;
      [MGIC, LGIC] = find(GIC==min(min(GIC)));LGIC= LGIC-1;
      [MMIC, LMIC] = find(MIC==min(min(MIC)));LMIC= LMIC-1;
      [Mmdl, Lmdl] = find(mdl==min(min(mdl)));Lmdl= Lmdl-1;
      [Mbic, Lbic] = find(bic==min(min(bic)));Lbic= Lbic-1;
      [Maic, Laic] = find(aic==min(min(aic)));Laic= Laic-1;
      [Mgic, Lgic] = find(gic==min(min(gic)));Lgic= Lgic-1;
      [Mmic, Lmic] = find(mic==min(min(mic)));Lmic= Lmic-1;

%      [N M L mm MMDL, LMDL, MBIC, LBIC, MAIC, LAIC, MGIC, LGIC, MMIC, LMIC]
%      [N M L mm Mmdl, Lmdl, Mbic, Lbic, Maic, Laic, Mgic, Lgic, Mmic, Lmic]

      MDLhist(MMDL, LMDL+1)= MDLhist(MMDL, LMDL+1) + 1;
      BIChist(MBIC, LBIC+1)= BIChist(MBIC, LBIC+1) + 1;
      AIChist(MAIC, LAIC+1)= AIChist(MAIC, LAIC+1) + 1;
      GIChist(MGIC, LGIC+1)= GIChist(MGIC, LGIC+1) + 1;
      MIChist(MMIC, LMIC+1)= MIChist(MMIC, LMIC+1) + 1;
      mdlhist(Mmdl, Lmdl+1)= mdlhist(Mmdl, Lmdl+1) + 1;
      bichist(Mbic, Lbic+1)= bichist(Mbic, Lbic+1) + 1;
      aichist(Maic, Laic+1)= aichist(Maic, Laic+1) + 1;
      gichist(Mgic, Lgic+1)= gichist(Mgic, Lgic+1) + 1;
      michist(Mmic, Lmic+1)= michist(Mmic, Lmic+1) + 1;
   end;
   MDLM= sum(MDLhist.').';MDLL= sum(MDLhist);
   BICM= sum(BIChist.').';BICL= sum(BIChist);
   AICM= sum(AIChist.').';AICL= sum(AIChist);
   GICM= sum(GIChist.').';GICL= sum(GIChist);
   MICM= sum(MIChist.').';MICL= sum(MIChist);
   mdlM= sum(mdlhist.').';mdlL= sum(mdlhist);
   bicM= sum(bichist.').';bicL= sum(bichist);
   aicM= sum(aichist.').';aicL= sum(aichist);
   gicM= sum(gichist.').';gicL= sum(gichist);
   micM= sum(michist.').';micL= sum(michist);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if(0)% TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(n);clf;
subplot(4, 2, 1);bar(MDLM, 1);axis([.5 Mmax+0.5 0 MM])
subplot(4, 2, 2);bar(MDLL, 1);axis([.5 Lmax+1.5 0 MM])
set(gca, 'XTick', 1:Lmax+1)
set(gca, 'XTickLabel', 0:Lmax)

subplot(4, 2, 3);bar(BICM, 1);axis([.5 Mmax+0.5 0 MM])
subplot(4, 2, 4);bar(BICL, 1);axis([.5 Lmax+1.5 0 MM])
set(gca, 'XTick', 1:Lmax+1)
set(gca, 'XTickLabel', 0:Lmax)

subplot(4, 2, 5);bar(AICM, 1);axis([.5 Mmax+0.5 0 MM])
subplot(4, 2, 6);bar(AICL, 1);axis([.5 Lmax+1.5 0 MM])
set(gca, 'XTick', 1:Lmax+1)
set(gca, 'XTickLabel', 0:Lmax)

subplot(4, 2, 7);bar(GICM, 1);axis([.5 Mmax+0.5 0 MM])
subplot(4, 2, 8);bar(GICL, 1);axis([.5 Lmax+1.5 0 MM])
set(gca, 'XTick', 1:Lmax+1)
set(gca, 'XTickLabel', 0:Lmax)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end;% TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mean= [
    sum((1:Mmax)'.*MDLM)/MM;
    sum((1:Mmax)'.*BICM)/MM;
    sum((1:Mmax)'.*AICM)/MM;
    sum((1:Mmax)'.*GICM)/MM;
    sum((1:Mmax)'.*MICM)/MM;
    sum((1:Mmax)'.*mdlM)/MM;
    sum((1:Mmax)'.*bicM)/MM;
    sum((1:Mmax)'.*aicM)/MM;
    sum((1:Mmax)'.*gicM)/MM;
    sum((1:Mmax)'.*micM)/MM;
    ];
meanMn= [meanMn mean];

mean= [
    sum((0:Lmax).*MDLL)/MM;
    sum((0:Lmax).*BICL)/MM;
    sum((0:Lmax).*AICL)/MM;
    sum((0:Lmax).*GICL)/MM;
    sum((0:Lmax).*MICL)/MM;
    sum((0:Lmax).*mdlL)/MM;
    sum((0:Lmax).*bicL)/MM;
    sum((0:Lmax).*aicL)/MM;
    sum((0:Lmax).*gicL)/MM;
    sum((0:Lmax).*micL)/MM;
    ];
meanLn= [meanLn mean];

mse= [
       10*log10((sum(((1:Mmax)'-M).^2.*MDLM) + sum(((0:Lmax)-L).^2.*MDLL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*BICM) + sum(((0:Lmax)-L).^2.*BICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*AICM) + sum(((0:Lmax)-L).^2.*AICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*GICM) + sum(((0:Lmax)-L).^2.*GICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*MICM) + sum(((0:Lmax)-L).^2.*MICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*mdlM) + sum(((0:Lmax)-L).^2.*mdlL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*bicM) + sum(((0:Lmax)-L).^2.*bicL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*aicM) + sum(((0:Lmax)-L).^2.*aicL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*gicM) + sum(((0:Lmax)-L).^2.*gicL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*micM) + sum(((0:Lmax)-L).^2.*micL))/MM/(M^2+L^2));
       ];
   MSEn= [MSEn mse];
   drawnow
end






N= 256;
L= 2;
MSEm= [];
meanMm= [];
meanLm= [];
for M= 2:5
   resultname= sprintf('data/%04d/%s%d%d%s%s.mat', N, exp, M, L, re_im, mo_no);
   load(resultname)
   sprintf('%s%4d', resultname, MM)
   switch(exp(end))
    case 'A'
     Ns= (2:(1+Mmax))'*(2*(0:Lmax)+1)-1;
    case 'B'
     Ns= (2:(1+Mmax))'*(2*(0:Lmax)+1)-1;
    case 'C'
     Ns= (2*(1:Mmax))'*(2*(0:Lmax)+1)-1;
   end;
   
if(sub)
   ee     = min(log(EE)     , [], 3);
   eeprime= min(log(EEprime), [], 3);
else
   ee     = log(EE(:, :, 1, :));
   eeprime= log(EEprime(:, :, 1, :));
end;

   MDLhist= zeros(Mmax, Lmax+1);
   BIChist= zeros(Mmax, Lmax+1);
   AIChist= zeros(Mmax, Lmax+1);
   GIChist= zeros(Mmax, Lmax+1);
   MIChist= zeros(Mmax, Lmax+1);
   mdlhist= zeros(Mmax, Lmax+1);
   bichist= zeros(Mmax, Lmax+1);
   aichist= zeros(Mmax, Lmax+1);
   gichist= zeros(Mmax, Lmax+1);
   michist= zeros(Mmax, Lmax+1);

   for mm= 1:MM
      e= ee(:, :, 1, mm);
      eprime= eeprime(:, :, 1, mm);
      MDL= eprime + (log(N+1)+rho)  *(Ns+1/2)/N;
      BIC= eprime + log(N)          *(Ns   )/N;
      AIC= eprime + 2               *(Ns   )/N;
      GIC= eprime + (2+rho)         *(Ns   )/N;
      MIC= eprime + (1+rho+log(N)/2)*(Ns   )/N;
      mdl= e + (log(N+1)+rho)  *(Ns+1/2)/N;
      bic= e + log(N)          *(Ns   )/N;
      aic= e + 2               *(Ns   )/N;
      gic= e + (2+rho)         *(Ns   )/N;
      mic= e + (1+rho+log(N)/2)*(Ns   )/N;

      [MMDL, LMDL] = find(MDL==min(min(MDL)));LMDL= LMDL-1;
      [MBIC, LBIC] = find(BIC==min(min(BIC)));LBIC= LBIC-1;
      [MAIC, LAIC] = find(AIC==min(min(AIC)));LAIC= LAIC-1;
      [MGIC, LGIC] = find(GIC==min(min(GIC)));LGIC= LGIC-1;
      [MMIC, LMIC] = find(MIC==min(min(MIC)));LMIC= LMIC-1;
      [Mmdl, Lmdl] = find(mdl==min(min(mdl)));Lmdl= Lmdl-1;
      [Mbic, Lbic] = find(bic==min(min(bic)));Lbic= Lbic-1;
      [Maic, Laic] = find(aic==min(min(aic)));Laic= Laic-1;
      [Mgic, Lgic] = find(gic==min(min(gic)));Lgic= Lgic-1;
      [Mmic, Lmic] = find(mic==min(min(mic)));Lmic= Lmic-1;

%      [N M L mm MMDL, LMDL, MBIC, LBIC, MAIC, LAIC, MGIC, LGIC, MMIC, LMIC]
%      [N M L mm Mmdl, Lmdl, Mbic, Lbic, Maic, Laic, Mgic, Lgic, Mmic, Lmic]

      MDLhist(MMDL, LMDL+1)= MDLhist(MMDL, LMDL+1) + 1;
      BIChist(MBIC, LBIC+1)= BIChist(MBIC, LBIC+1) + 1;
      AIChist(MAIC, LAIC+1)= AIChist(MAIC, LAIC+1) + 1;
      GIChist(MGIC, LGIC+1)= GIChist(MGIC, LGIC+1) + 1;
      MIChist(MMIC, LMIC+1)= MIChist(MMIC, LMIC+1) + 1;
      mdlhist(Mmdl, Lmdl+1)= mdlhist(Mmdl, Lmdl+1) + 1;
      bichist(Mbic, Lbic+1)= bichist(Mbic, Lbic+1) + 1;
      aichist(Maic, Laic+1)= aichist(Maic, Laic+1) + 1;
      gichist(Mgic, Lgic+1)= gichist(Mgic, Lgic+1) + 1;
      michist(Mmic, Lmic+1)= michist(Mmic, Lmic+1) + 1;
   end;
   MDLM= sum(MDLhist.').';MDLL= sum(MDLhist);
   BICM= sum(BIChist.').';BICL= sum(BIChist);
   AICM= sum(AIChist.').';AICL= sum(AIChist);
   GICM= sum(GIChist.').';GICL= sum(GIChist);
   MICM= sum(MIChist.').';MICL= sum(MIChist);
   mdlM= sum(mdlhist.').';mdlL= sum(mdlhist);
   bicM= sum(bichist.').';bicL= sum(bichist);
   aicM= sum(aichist.').';aicL= sum(aichist);
   gicM= sum(gichist.').';gicL= sum(gichist);
   micM= sum(michist.').';micL= sum(michist);

mean= [
    sum((1:Mmax)'.*MDLM)/MM;
    sum((1:Mmax)'.*BICM)/MM;
    sum((1:Mmax)'.*AICM)/MM;
    sum((1:Mmax)'.*GICM)/MM;
    sum((1:Mmax)'.*MICM)/MM;
    sum((1:Mmax)'.*mdlM)/MM;
    sum((1:Mmax)'.*bicM)/MM;
    sum((1:Mmax)'.*aicM)/MM;
    sum((1:Mmax)'.*gicM)/MM;
    sum((1:Mmax)'.*micM)/MM;
    ];
meanMm= [meanMm mean];

mean= [
    sum((0:Lmax).*MDLL)/MM;
    sum((0:Lmax).*BICL)/MM;
    sum((0:Lmax).*AICL)/MM;
    sum((0:Lmax).*GICL)/MM;
    sum((0:Lmax).*MICL)/MM;
    sum((0:Lmax).*mdlL)/MM;
    sum((0:Lmax).*bicL)/MM;
    sum((0:Lmax).*aicL)/MM;
    sum((0:Lmax).*gicL)/MM;
    sum((0:Lmax).*micL)/MM;
    ];
meanLm= [meanLm mean];

   mse= [
       10*log10((sum(((1:Mmax)'-M).^2.*MDLM) + sum(((0:Lmax)-L).^2.*MDLL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*BICM) + sum(((0:Lmax)-L).^2.*BICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*AICM) + sum(((0:Lmax)-L).^2.*AICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*GICM) + sum(((0:Lmax)-L).^2.*GICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*MICM) + sum(((0:Lmax)-L).^2.*MICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*mdlM) + sum(((0:Lmax)-L).^2.*mdlL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*bicM) + sum(((0:Lmax)-L).^2.*bicL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*aicM) + sum(((0:Lmax)-L).^2.*aicL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*gicM) + sum(((0:Lmax)-L).^2.*gicL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*micM) + sum(((0:Lmax)-L).^2.*micL))/MM/(M^2+L^2));
       ];
   MSEm= [MSEm mse];
   drawnow
end;














N= 256;
M= 2;
MSEl= [];
meanMl= [];
meanLl= [];
for L= 0:3
   resultname= sprintf('data/%04d/%s%d%d%s%s.mat', N, exp, M, L, re_im, mo_no);
   load(resultname)
   sprintf('%s%4d', resultname, MM)
   switch(exp(end))
    case 'A'
     Ns= (2:(1+Mmax))'*(2*(0:Lmax)+1)-1;
    case 'B'
     Ns= (2:(1+Mmax))'*(2*(0:Lmax)+1)-1;
    case 'C'
     Ns= (2*(1:Mmax))'*(2*(0:Lmax)+1)-1;
   end;
   
if(sub)
   ee     = min(log(EE)     , [], 3);
   eeprime= min(log(EEprime), [], 3);
else
   ee     = log(EE(:, :, 1, :));
   eeprime= log(EEprime(:, :, 1, :));
end;

   MDLhist= zeros(Mmax, Lmax+1);
   BIChist= zeros(Mmax, Lmax+1);
   AIChist= zeros(Mmax, Lmax+1);
   GIChist= zeros(Mmax, Lmax+1);
   MIChist= zeros(Mmax, Lmax+1);
   mdlhist= zeros(Mmax, Lmax+1);
   bichist= zeros(Mmax, Lmax+1);
   aichist= zeros(Mmax, Lmax+1);
   gichist= zeros(Mmax, Lmax+1);
   michist= zeros(Mmax, Lmax+1);

   for mm= 1:MM
      e= ee(:, :, 1, mm);
      eprime= eeprime(:, :, 1, mm);
      MDL= eprime + (log(N+1)+rho)  *(Ns+1/2)/N;
      BIC= eprime + log(N)          *(Ns   )/N;
      AIC= eprime + 2               *(Ns   )/N;
      GIC= eprime + (2+rho)         *(Ns   )/N;
      MIC= eprime + (1+rho+log(N)/2)*(Ns   )/N;
      mdl= e + (log(N+1)+rho)  *(Ns+1/2)/N;
      bic= e + log(N)          *(Ns   )/N;
      aic= e + 2               *(Ns   )/N;
      gic= e + (2+rho)         *(Ns   )/N;
      mic= e + (1+rho+log(N)/2)*(Ns   )/N;

      [MMDL, LMDL] = find(MDL==min(min(MDL)));LMDL= LMDL-1;
      [MBIC, LBIC] = find(BIC==min(min(BIC)));LBIC= LBIC-1;
      [MAIC, LAIC] = find(AIC==min(min(AIC)));LAIC= LAIC-1;
      [MGIC, LGIC] = find(GIC==min(min(GIC)));LGIC= LGIC-1;
      [MMIC, LMIC] = find(MIC==min(min(MIC)));LMIC= LMIC-1;
      [Mmdl, Lmdl] = find(mdl==min(min(mdl)));Lmdl= Lmdl-1;
      [Mbic, Lbic] = find(bic==min(min(bic)));Lbic= Lbic-1;
      [Maic, Laic] = find(aic==min(min(aic)));Laic= Laic-1;
      [Mgic, Lgic] = find(gic==min(min(gic)));Lgic= Lgic-1;
      [Mmic, Lmic] = find(mic==min(min(mic)));Lmic= Lmic-1;

%      [N M L mm MMDL, LMDL, MBIC, LBIC, MAIC, LAIC, MGIC, LGIC, MMIC, LMIC]
%      [N M L mm Mmdl, Lmdl, Mbic, Lbic, Maic, Laic, Mgic, Lgic, Mmic, Lmic]

      MDLhist(MMDL, LMDL+1)= MDLhist(MMDL, LMDL+1) + 1;
      BIChist(MBIC, LBIC+1)= BIChist(MBIC, LBIC+1) + 1;
      AIChist(MAIC, LAIC+1)= AIChist(MAIC, LAIC+1) + 1;
      GIChist(MGIC, LGIC+1)= GIChist(MGIC, LGIC+1) + 1;
      MIChist(MMIC, LMIC+1)= MIChist(MMIC, LMIC+1) + 1;
      mdlhist(Mmdl, Lmdl+1)= mdlhist(Mmdl, Lmdl+1) + 1;
      bichist(Mbic, Lbic+1)= bichist(Mbic, Lbic+1) + 1;
      aichist(Maic, Laic+1)= aichist(Maic, Laic+1) + 1;
      gichist(Mgic, Lgic+1)= gichist(Mgic, Lgic+1) + 1;
      michist(Mmic, Lmic+1)= michist(Mmic, Lmic+1) + 1;
   end;
   MDLM= sum(MDLhist.').';MDLL= sum(MDLhist);
   BICM= sum(BIChist.').';BICL= sum(BIChist);
   AICM= sum(AIChist.').';AICL= sum(AIChist);
   GICM= sum(GIChist.').';GICL= sum(GIChist);
   MICM= sum(MIChist.').';MICL= sum(MIChist);
   mdlM= sum(mdlhist.').';mdlL= sum(mdlhist);
   bicM= sum(bichist.').';bicL= sum(bichist);
   aicM= sum(aichist.').';aicL= sum(aichist);
   gicM= sum(gichist.').';gicL= sum(gichist);
   micM= sum(michist.').';micL= sum(michist);

mean= [
    sum((1:Mmax)'.*MDLM)/MM;
    sum((1:Mmax)'.*BICM)/MM;
    sum((1:Mmax)'.*AICM)/MM;
    sum((1:Mmax)'.*GICM)/MM;
    sum((1:Mmax)'.*MICM)/MM;
    sum((1:Mmax)'.*mdlM)/MM;
    sum((1:Mmax)'.*bicM)/MM;
    sum((1:Mmax)'.*aicM)/MM;
    sum((1:Mmax)'.*gicM)/MM;
    sum((1:Mmax)'.*micM)/MM;
    ];
meanMl= [meanMl mean];

mean= [
    sum((0:Lmax).*MDLL)/MM;
    sum((0:Lmax).*BICL)/MM;
    sum((0:Lmax).*AICL)/MM;
    sum((0:Lmax).*GICL)/MM;
    sum((0:Lmax).*MICL)/MM;
    sum((0:Lmax).*mdlL)/MM;
    sum((0:Lmax).*bicL)/MM;
    sum((0:Lmax).*aicL)/MM;
    sum((0:Lmax).*gicL)/MM;
    sum((0:Lmax).*micL)/MM;
    ];
meanLl= [meanLl mean];

   mse= [
       10*log10((sum(((1:Mmax)'-M).^2.*MDLM) + sum(((0:Lmax)-L).^2.*MDLL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*BICM) + sum(((0:Lmax)-L).^2.*BICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*AICM) + sum(((0:Lmax)-L).^2.*AICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*GICM) + sum(((0:Lmax)-L).^2.*GICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*MICM) + sum(((0:Lmax)-L).^2.*MICL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*mdlM) + sum(((0:Lmax)-L).^2.*mdlL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*bicM) + sum(((0:Lmax)-L).^2.*bicL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*aicM) + sum(((0:Lmax)-L).^2.*aicL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*gicM) + sum(((0:Lmax)-L).^2.*gicL))/MM/(M^2+L^2));
       10*log10((sum(((1:Mmax)'-M).^2.*micM) + sum(((0:Lmax)-L).^2.*micL))/MM/(M^2+L^2));
       ];
   MSEl= [MSEl mse];
   drawnow
end;

figure(fig)
subplot(3, 3, 1);
   plot(MSEn(1, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'k')
%   plot(MSEn(2, :), 'Linewidth', 2, 'Linestyle', ':' , 'Color', 'k')
   plot(MSEn(3, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'k')
%   plot(MSEn(4, :), 'Linewidth', 2, 'Linestyle', ':', 'Color', 'k')
%   plot(MSEn(5, :), 'Linewidth', 2, 'Linestyle', '.' , 'Color', 'k')
if(test)
   plot(MSEn(6, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'r')
%   plot(MSEn(7, :), 'Linewidth', 1, 'Linestyle', ':' , 'Color', 'r')
   plot(MSEn(8, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'r')
%   plot(MSEn(9, :), 'Linewidth', 1, 'Linestyle', ':', 'Color', 'r')
%   plot(MSEn(10,:), 'Linewidth', 1, 'Linestyle', '.' , 'Color', 'r')
end;

subplot(3, 3, 2);
   plot(MSEm(1, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'k')
%   plot(MSEm(2, :), 'Linewidth', 2, 'Linestyle', ':' , 'Color', 'k')
   plot(MSEm(3, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'k')
%   plot(MSEm(4, :), 'Linewidth', 2, 'Linestyle', ':', 'Color', 'k')
%   plot(MSEm(5, :), 'Linewidth', 2, 'Linestyle', '.' , 'Color', 'k')
if(test)
   plot(MSEm(6, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'r')
%   plot(MSEm(7, :), 'Linewidth', 1, 'Linestyle', ':' , 'Color', 'r')
   plot(MSEm(8, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'r')
%   plot(MSEm(9, :), 'Linewidth', 1, 'Linestyle', ':', 'Color', 'r')
%   plot(MSEm(10,:), 'Linewidth', 1, 'Linestyle', '.' , 'Color', 'r')
end;

subplot(3, 3, 3);
   plot(MSEl(1, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'k')
%   plot(MSEl(2, :), 'Linewidth', 2, 'Linestyle', ':' , 'Color', 'k')
   plot(MSEl(3, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'k')
%   plot(MSEl(4, :), 'Linewidth', 2, 'Linestyle', ':', 'Color', 'k')
%   plot(MSEl(5, :), 'Linewidth', 2, 'Linestyle', '.' , 'Color', 'k')
if(test)
   plot(MSEl(6, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'r')
%   plot(MSEl(7, :), 'Linewidth', 1, 'Linestyle', ':' , 'Color', 'r')
   plot(MSEl(8, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'r')
%   plot(MSEl(9, :), 'Linewidth', 1, 'Linestyle', ':', 'Color', 'r')
%   plot(MSEl(10,:), 'Linewidth', 1, 'Linestyle', '.' , 'Color', 'r')
end;

subplot(3, 3, 4);
   plot(meanMn(1, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'k')
%   plot(meanMn(2, :), 'Linewidth', 2, 'Linestyle', ':' , 'Color', 'k')
   plot(meanMn(3, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'k')
%   plot(meanMn(4, :), 'Linewidth', 2, 'Linestyle', ':', 'Color', 'k')
%   plot(meanMn(5, :), 'Linewidth', 2, 'Linestyle', '.' , 'Color', 'k')
%   plot([3 3 3 3], 'Linewidth', 1, 'Linestyle', '-', 'Color', 'k')
if(test)
   plot(meanMn(6, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'r')
%   plot(meanMn(7, :), 'Linewidth', 1, 'Linestyle', ':' , 'Color', 'r')
   plot(meanMn(8, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'r')
%   plot(meanMn(9, :), 'Linewidth', 1, 'Linestyle', ':', 'Color', 'r')
%   plot(meanMn(10,:), 'Linewidth', 1, 'Linestyle', '--', 'Color', 'r')
end;

subplot(3, 3, 5);
   plot(meanMm(1, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'k')
%   plot(meanMm(2, :), 'Linewidth', 2, 'Linestyle', ':' , 'Color', 'k')
   plot(meanMm(3, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'k')
%   plot(meanMm(4, :), 'Linewidth', 2, 'Linestyle', ':', 'Color', 'k')
%   plot(meanMm(5, :), 'Linewidth', 2, 'Linestyle', '.' , 'Color', 'k')
%   plot([2 3 4 5], 'Linewidth', 1, 'Linestyle', '-', 'Color', 'k')
if(test)
   plot(meanMm(6, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'r')
%   plot(meanMm(7, :), 'Linewidth', 1, 'Linestyle', ':' , 'Color', 'r')
   plot(meanMm(8, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'r')
%   plot(meanMm(9, :), 'Linewidth', 1, 'Linestyle', ':', 'Color', 'r')
%   plot(meanMm(10,:), 'Linewidth', 1, 'Linestyle', '--', 'Color', 'r')
end;

subplot(3, 3, 6);
   plot(meanMl(1, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'k')
%   plot(meanMl(2, :), 'Linewidth', 2, 'Linestyle', ':' , 'Color', 'k')
   plot(meanMl(3, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'k')
%   plot(meanMl(4, :), 'Linewidth', 2, 'Linestyle', ':', 'Color', 'k')
%   plot(meanMl(5, :), 'Linewidth', 2, 'Linestyle', '.' , 'Color', 'k')
%   plot([3 3 3 3], 'Linewidth', 1, 'Linestyle', '-', 'Color', 'k')
if(test)
   plot(meanMl(6, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'r')
%   plot(meanMl(7, :), 'Linewidth', 1, 'Linestyle', ':' , 'Color', 'r')
   plot(meanMl(8, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'r')
%   plot(meanMl(9, :), 'Linewidth', 1, 'Linestyle', ':', 'Color', 'r')
%   plot(meanMl(10,:), 'Linewidth', 1, 'Linestyle', '--', 'Color', 'r')
end;

subplot(3, 3, 7);
   plot(meanLn(1, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'k')
%   plot(meanLn(2, :), 'Linewidth', 2, 'Linestyle', ':' , 'Color', 'k')
   plot(meanLn(3, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'k')
%   plot(meanLn(4, :), 'Linewidth', 2, 'Linestyle', ':', 'Color', 'k')
%   plot(meanLn(5, :), 'Linewidth', 2, 'Linestyle', '.' , 'Color', 'k')
%   plot([2 2 2 2], 'Linewidth', 1, 'Linestyle', '-', 'Color', 'k')
if(test)
   plot(meanLn(6, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'r')
%   plot(meanLn(7, :), 'Linewidth', 1, 'Linestyle', ':' , 'Color', 'r')
   plot(meanLn(8, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'r')
%   plot(meanLn(9, :), 'Linewidth', 1, 'Linestyle', ':', 'Color', 'r')
%   plot(meanLn(10,:), 'Linewidth', 1, 'Linestyle', '--', 'Color', 'r')
end;

subplot(3, 3, 8);
   plot(meanLm(1, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'k')
%   plot(meanLm(2, :), 'Linewidth', 2, 'Linestyle', ':' , 'Color', 'k')
   plot(meanLm(3, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'k')
%   plot(meanLm(4, :), 'Linewidth', 2, 'Linestyle', ':', 'Color', 'k')
%   plot(meanLm(5, :), 'Linewidth', 2, 'Linestyle', '.' , 'Color', 'k')
%   plot([2 2 2 2], 'Linewidth', 1, 'Linestyle', '-', 'Color', 'k')
if(test)
   plot(meanLm(6, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'r')
%   plot(meanLm(7, :), 'Linewidth', 1, 'Linestyle', ':' , 'Color', 'r')
   plot(meanLm(8, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'r')
%   plot(meanLm(9, :), 'Linewidth', 1, 'Linestyle', ':', 'Color', 'r')
%   plot(meanLm(10,:), 'Linewidth', 1, 'Linestyle', '--', 'Color', 'r')
end;

subplot(3, 3, 9);
   plot(meanLl(1, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'k')
%   plot(meanLl(2, :), 'Linewidth', 2, 'Linestyle', ':' , 'Color', 'k')
   plot(meanLl(3, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'k')
%   plot(meanLl(4, :), 'Linewidth', 2, 'Linestyle', ':', 'Color', 'k')
%   plot(meanLl(5, :), 'Linewidth', 2, 'Linestyle', '.' , 'Color', 'k')
%   plot([0 1 2 3], 'Linewidth', 1, 'Linestyle', '-', 'Color', 'k')
if(test)
   plot(meanLl(6, :), 'Linewidth', 2, 'Linestyle', style, 'Color', 'r')
%   plot(meanLl(7, :), 'Linewidth', 1, 'Linestyle', ':' , 'Color', 'r')
   plot(meanLl(8, :), 'Linewidth', 1, 'Linestyle', style, 'Color', 'r')
%   plot(meanLl(9, :), 'Linewidth', 1, 'Linestyle', ':', 'Color', 'r')
%   plot(meanLl(10,:), 'Linewidth', 1, 'Linestyle', '--', 'Color', 'r')
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if(0)% TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;tfpm
fig= 81
test= 0;
sub= 1;
figure(fig);clf
subplot(3, 3, 1);cla;hold on
subplot(3, 3, 2);cla;hold on
subplot(3, 3, 3);cla;hold on
subplot(3, 3, 4);cla;hold on
subplot(3, 3, 5);cla;hold on
subplot(3, 3, 6);cla;hold on
subplot(3, 3, 7);cla;hold on
subplot(3, 3, 8);cla;hold on
subplot(3, 3, 9);cla;hold on
plot_fit('ord2A', fig, '-',  test, sub)
plot_fit('ord2B', fig, '--', test, sub)
plot_fit('ord2C', fig, '-.', test, sub)


subplot(3, 3, 1);
   axis([1 4 -30 0]);box;grid
   set(gca, 'XTick', 1:4)
   set(gca, 'XTicklabel', 2.^(6:9))
   set(gca, 'YTick', -30:5:0)
   ylabel('MSE')
   xlabel('N')
subplot(3, 3, 2);
   axis([1 4 -30 0]);box;grid
   set(gca, 'XTick', 1:4)
   set(gca, 'XTicklabel', 2:5)
   set(gca, 'YTick', -30:5:0)
   ylabel('MSE')
   xlabel('M')
subplot(3, 3, 3);
   axis([1 4 -30 0]);box;grid
   set(gca, 'XTick', 1:5)
   set(gca, 'XTicklabel', 0:4)
   set(gca, 'YTick', -30:5:0)
   ylabel('MSE')
   xlabel('L')
subplot(3, 3, 4);
   axis([1 4 1 5]);box;grid
   set(gca, 'XTick', 1:4)
   set(gca, 'XTicklabel', 2.^(6:9))
   set(gca, 'YTick', 1:5)
   ylabel('Mbar')
   xlabel('N')
subplot(3, 3, 5);
   axis([1 4 1 5]);box;grid
   set(gca, 'XTick', 1:4)
   set(gca, 'XTicklabel', 2:5)
   set(gca, 'YTick', 1:5)
   ylabel('Mbar')
   xlabel('M')
subplot(3, 3, 6);
   axis([1 4 1 5]);box;grid
   set(gca, 'XTick', 1:5)
   set(gca, 'XTicklabel', 0:4)
   set(gca, 'YTick', 1:5)
   ylabel('Mbar')
   xlabel('L')
subplot(3, 3, 7);
   axis([1 4 0 4]);box;grid
   set(gca, 'XTick', 1:4)
   set(gca, 'XTicklabel', 2.^(6:9))
   set(gca, 'YTick', 0:4)
   ylabel('Lbar')
   xlabel('N')
subplot(3, 3, 8);
   axis([1 4 0 4]);box;grid
   set(gca, 'XTick', 1:4)
   set(gca, 'XTicklabel', 2:5)
   set(gca, 'YTick', 0:4)
   ylabel('Lbar')
   xlabel('M')
subplot(3, 3, 9);
   axis([1 4 0 4]);box;grid
   set(gca, 'XTick', 1:5)
   set(gca, 'XTicklabel', 0:4)
   set(gca, 'YTick', 0:4)
   ylabel('Lbar')
   xlabel('L')

print -deps2 -tiff -r300 /users/mjachan/tex/prj/TF/figures/ordMSE.eps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end;% TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%