function [Decisions, MSE] = SimpleSlicer( MFOut, Alphabet, Scale )
% SimpleSlicer - decisons from matched filter outputs
%
% SimpleSlicer makes decisions about transmitted symbols given the outputs
% from a matched filter and the (appropriately scaled) signal
% constellation. 
%
% SimpleSlicer assumes implicitly that all symbols are equally likely.
%
% Inputs:
%   MFOut     - outputs from the matched filter (one sample per symbol)
%   Alphabet  - signal constellation 
%   Scale     - gain for symbols during transmission (typically
%               A*Pulse*Pulse')
% Outputs:
%   Decisions - estimated symbols
%   MSE       - mean-squared error (estimate for variance)
%
% Example:
%   [Decisions, MSE] = SimpleSlicer( MFOut, Alphabet, Scale )

%% Initialization
MinDist = Inf*ones( size( MFOut ) );

%% Loop over symbols to find symbol closest to MF output
for kk = 1:length( Alphabet )
    % noise-free signal location
    NoisefreeSig = Scale*Alphabet(kk);
    % Euclidean distance between each observation and constellation point
    Dist         = abs( MFOut - NoisefreeSig );
    % find locations for which distance is smaller than previous best
    ChangedDec   = ( Dist < MinDist );
    
    % store new min distances and update decisions
    MinDist( ChangedDec)    = Dist( ChangedDec );
    Decisions( ChangedDec ) = Alphabet(kk);
end

MSE = mean( MinDist.^2 );