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

clear;

volumes_noswap = textread('data-allswap/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)

% Compute g for each t.
g_t = ones(T,1);
Neff_t = zeros(T,1);
for t = 1:T
  g_t(t) = statistical_inefficiency(A_t(T:-1:t));
  Neff_t(t) = (T-t+1) / g_t(t);
end

% Plot
clf

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

subplot(3,1,2);
plot(1:T, g_t, 'k.');
xlabel('production start');
ylabel('g');

subplot(3,1,3);
plot(1:T, Neff_t, 'k.');
xlabel('production start');
ylabel('N_{eff}');

