csci5521/assignments/hwk03/Q_step.m
2023-11-18 02:40:46 -06:00

11 lines
245 B
Matlab

function [LL] = Q_step(x, m, S, k, pi, h, flag)
[num_data, ~] = size(x);
LL = 0;
for i = 1:k
N = mvnpdf(x, m(i, :), S(:, :, i));
for j = 1:num_data
LL = LL + h(j, i) * (log(pi(i) + eps) + log(N(j) + eps));
end
end
end