% perform one iteration of EM for the x4 example.

% set LLSQ coefficient matrix
%
  B = get_A( b, N, Memory);

% set G and FIR
%
% for deterministic h
%
%  G = [];
%
% for uniform h
%
%  G = var_noise * inv(B'*B);
%  FIR = B\(z');
%
% for Gaussian h
%
  if( isempty(G))
%
% with get_A() fix, 9 April 2000, B can be singular,
% so use pinv()
%
% old:
%    FIR = B\(z');
%
    FIR = pinv(B)*(z');
  else
    G = inv( (B'*B)/var_noise + inv_Rh);
    FIR = G * (B'*(z')/var_noise + inv_Rh*avg_h);
  end

% set new FSM state transition cost matrix
%
  trans = FSM_trans( states, FIR);

% run the viterbi algorithm
%
  vit_C;

% save data estimates in b
%
  b = get_ex;

% check accuracy
%
%  sum( b' ~= x)
