TP-traitement-audio-visuel/TP4/probabilites_EM.m
2023-06-22 20:47:16 +02:00

16 lines
430 B
Matlab

function probas = probabilites_EM(proportions, moyennes, variances, poids)
x = 1:255;
nb_classes = length(poids);
nb_points = length(x);
probas = zeros(nb_points, nb_classes);
sigma = sqrt(variances);
for k=1:nb_classes
probas(:,k) = ( proportions(k) * poids(k) / sigma(k) / sqrt(2*pi) ) .* exp( - (x - moyennes(k)).^2 ./ (2*variances(k)) );
end
probas = probas ./ sum(probas, 2);
end