% This function takes a set of gaussian distributions (gaussians), their
% probabilities (pi_k) and determines the likelihood that a data sample is
% generated from that distribution.

function output_cluster_assignment = choose_cluster(gaussians, pi_k, data)
    llh = zeros(size(data,1),length(gaussians));
    % Calculate the likelihood by calculating the value from the pdf and
    % multiplying it by the mixture's likelihood
    for i = 1:length(gaussians)
        if ~isempty(gaussians{i})
            llh(:,i) = pdf(gaussians{i}, data)*pi_k(i);
        end
    end
    
    [~,output_cluster_assignment] = max(llh,[],2);
    
end