% Pruebas de la influencia del periodo de muestreo en la precision

%%%%precision1
R = 9000000;
buffer = inf;
%%%%precision2
R = 7000000;
buffer = 200000;
%%%%precision3
%R = 8000000;
%buffer = 1000000;
bins = 10;
oversampling = 10;

load Mawi1999B_T1h

maxT = 90000*0.04*1e6; 

fprintf('\n\nR = %g, B = %g\n\n', R, buffer);

clf

 

k = 1;
for periodo = [0.01, 0.02, 0.04, 0.1, 0.5, 1, 2, 4, 10, 20]

    fprintf('%g ', periodo);
    [B, CLRs, L] = HML_BufferT( Mawi1999B_T1h, R, buffer, periodo, maxT);
    fprintf('OK! CLR =%g  ', CLRs);


    % Calculo por histograms 
    LH = HML_Hist2( L, bins);
    if (periodo == 1) oversampling = oversampling * 10; end;
    if (periodo == 10) oversampling = oversampling * 10; end;
    LHO = HML_HStretch(LH, oversampling);
    [RFBH, CLR, i] = HML_HBufferSP(LHO, R, buffer, periodo);
    fprintf('OK! CLR =%g  ', CLR);
    CLR1(1,k) = periodo;
    CLR1(2,k) = CLR;
    
    
    % Calcula diferencias
    HBS = HML_HistB( B, RFBH(1,:));
    D1(1,k) = periodo;
    D1(2,k) = norm(RFBH(2,:)-HBS(2,:));
    fprintf('Diferencias %g \n', periodo, D1(2,k));
    
    k = k + 1;
    
end




clf
loglog(D1(1,:),D1(2,:));
xlabel('period');

pause
clf
loglog(CLR1(1,:),abs(CLR1(2,:)-CLRs)/CLRs);
xlabel('period');

