csci5521/assignments/hwk03/Q_step.m

12 lines
245 B
Mathematica
Raw Permalink Normal View History

2023-11-18 08:40:46 +00:00
function [LL] = Q_step(x, m, S, k, pi, h, flag)
2023-11-17 02:23:38 +00:00
[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