我正在尝试将 3 个正态分布的混合拟合到我的转换数据日志中,但我有点困惑如何去做。我尝试了 scikit learn python 中的 gmm 函数,但它似乎无法正常工作。
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()
最后我想得到一个 3 个分量的 pdf 图,即 f=f1+f2+f3。但是它不起作用。
是因为我试图将法线混合到对数正态数据中吗?
您能否解释我的错误和/或就用于拟合对数正态混合的软件包提供建议?