% ML exhaustive search for non-time-varying Gaussian h
%
% assumes that the symobls are -1 and +1
%
function min_b = get_ML()

global z;
global N;
global Memory;
global var_noise;
global avg_h;
global Rh;
global HUGE_VAL;

s = [-1; 1];
nsyms = size(s,1);
nstates = prod( nsyms*ones(1,N));	% nstates = nsyms ** N

c = ones( 1, N);

min_cost = HUGE_VAL;

for i = 1:nstates
  b = s(c);
  A = get_A( b, N, Memory);
  R = A*Rh*A' + diag(var_noise*ones(N,1));
  t = z' - A*avg_h;
  cost = t'*(inv(R)*t) + log(det(R));
  if( cost < min_cost)
    min_cost = cost;
    min_b = b;
  end
  c = FSM_inc( c, nsyms);
end
