16 lines
430 B
Mathematica
16 lines
430 B
Mathematica
|
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
|
||
|
|