I'm trying to fit a mixture of 3 normal distributions to my log of transformed data and I'm a bit confused how to do it. I tried gmm function from scikit learn python but it does not seem to work correctly.
g = mixture.GMM(n_components=3)
g.fit(lines)
f1 = arange(0, 13, 0.01)
f2 = arange(0, 13, 0.01)
f3 = arange(0, 13, 0.01)
f = arange(0, 13, 0.01)
for x in arange(0, 13, 0.01):
f1[x] = numpy.round(g.weights_[0],5) * numpy.exp(-numpy.power(x - means[0], 2) / 2 * numpy.power(covars[0], 2)) * (1 / (covars[0] * numpy.power(2 * pi, 0.5)))
f2[x] = numpy.round(g.weights_[1],5) * numpy.exp(-numpy.power(x - means[1], 2) / 2 * numpy.power(covars[1], 2)) * (1 / (covars[1] * numpy.power(2 * pi, 0.5)))
f3[x] = numpy.round(g.weights_[2],5) * numpy.exp(-numpy.power(x - means[2], 2) / 2 * numpy.power(covars[2], 2)) * (1 / (covars[2] * numpy.power(2 * pi, 0.5)))
f=f1+f2+f3
plt.plot(f)
plt.show()
In the end I want to get a pdf plot of 3 components, i.e. f=f1+f2+f3. However it doesn't work.
Is it because I'm trying to fit a mixture of normals to lognormal data?
Could you please explain my mistake and/or advise me on a package that is used for fitting mixture of lognormals?