% Test a simple algorithm for determining how much initial data to discard.

clear;

volumes_noswap = textread('data-noswap/volumes.out');

% Determine number of states.
nstates = size(volumes_noswap,2);
nsamples = size(volumes_noswap,1);

A_t = squeeze(volumes_noswap(:,12));
T = length(A_t)

nskip = 25;
t0_t = zeros(T,1);
g_t = zeros(T,1);
Neff_t = zeros(T,1);
for tmax = 1:nskip:T
  if mod(tmax, 100) == 0
    tmax
  end
  [t0, g, Neff] = detect_equilibration(A_t(1:tmax));
  t0_t(tmax) = t0;
  g_t(tmax) = g;
  Neff_t(tmax) = Neff;
end

% Plot
clf

subplot(4,1,1);
plot(1:T, A_t, 'k.');
xlabel('t');
ylabel('A_t');
axis([0 T min(A_t) max(A_t)]);

subplot(4,1,2);
plot(1:nskip:T, t0_t(1:nskip:T), 'k.');
xlabel('tmax');
ylabel('t_0');

subplot(4,1,3);
plot(1:nskip:T, g_t(1:nskip:T), 'k.');
xlabel('tmax');
ylabel('g');

subplot(4,1,4);
plot(1:nskip:T, Neff_t(1:nskip:T), 'k.');
xlabel('tmax');
ylabel('N_{eff}');

