EM算法的缓冲区溢出

时间:2016-03-23 06:59:08

标签: python algorithm

我正在尝试为高斯混合实现EM算法。我基于以下教程:

http://people.duke.edu/~ccc14/sta-663/EMAlgorithm.html

该算法适用于某些值,但是当数字较大时,我通常会在矩阵上得到无穷大。

这是我的代码:

    Traceback (most recent call last):
      File "C:\Usy", line 82, in <module>
        ll1, pis1, mus1, sigmas1 = em_gmm_orig(xs, pis, mus, sigmas)
      File "C:\Usy", line 48, in em_gmm_orig
        s += pis[j] * mvn(mus[j], sigmas[j]).pdf(xs[i])
      File "y", line 354, in __call__
        allow_singular=allow_singular)
...
    ValueError: array must not contain infs or NaNs

我通常会收到以下错误:

a = [1, 2, 3, 4, 5]
b = [1.360, 0.085, -1.190, -0.340, 3.698]

有什么方法可以解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

最有可能的是,你的sigma值在mvn中为零(mus [j],sigmas [j])。pdf(xs [i])给出了奇点。您可能想检查您的西格玛值。

相关问题