zxytim / fast-gmm

a Gaussian Mixture Model (GMM) implementation.
MIT License
30 stars 8 forks source link

Question about GMM::probability_of #3

Open eroehrig opened 6 years ago

eroehrig commented 6 years ago

https://github.com/zxytim/fast-gmm/blob/5b6940d62c950889d51d5a3dfc99907e3b631958/src/gmm.cc#L232-L235

It should be prob += weights[i] * gaussians[i]->probability_of(x), shouldn't it be?

zxytim commented 6 years ago

No. Probabilities are multiplicative, while log-probabilities are additive. See https://github.com/zxytim/fast-gmm/blob/5b6940d62c950889d51d5a3dfc99907e3b631958/src/gmm.cc#L244

eroehrig commented 6 years ago

I think the probabilities of the different gaussians are additive (see at wikipedia). The example you gave me, is the sum of the log_probability of more than one datapoint. That refers to

https://github.com/zxytim/fast-gmm/blob/5b6940d62c950889d51d5a3dfc99907e3b631958/src/gmm.cc#L215-L220

where it is done correctly. Because the probabilities are summed up before the log operation. There should be no difference to GMM::probability_of except of the log operation in the end.

AlexanderFabisch commented 6 years ago

A Gaussian mixture model is a weighted sum of Gaussians. I would say + is correct here.