function [t, g, Neff_max] = detect_equilibration(A_t)

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

[Neff_max, t] = max(Neff_t);
g = g_t(t);

return 

