【问题标题】:scikitlearn- How can I get cdf of a gaussian mixture model?scikit learn-如何获得高斯混合模型的 cdf?
【发布时间】:2018-07-16 18:54:09
【问题描述】:

现在我正在做这样的事情,我想知道是否有更好的方法。

import numpy as np
from scipy import integrate
from sklearn.mixture import GaussianMixture as GMM

model = GMM(n, covariance_type = "full").fit(X)

def cdf(x):
 return integrate.quad(lambda t: np.exp(model.score(t)), -inf, x)[0]

【问题讨论】:

  • 我是否认为您的数据是一维的?
  • 是的,你是对的
  • model.score(t) 中的 t 是什么?

标签: python scikit-learn cdf mixture-model


【解决方案1】:

混合高斯分布的 CDF 为 F_1,F_2,F_3...,权重为 ω_1,ω_2,ω_3...,等于 F_mixed = ω_1 * F_1 + ω_2 * F_2 + ω_3 * F_3 + 。 ..因此,答案是:

from scipy.stats import norm

weights = [0.163, 0.131, 0.486, 0.112, 0.107]
means = [45.279, 55.969, 49.315, 53.846, 61.953]
covars = [0.047, 1.189, 3.632, 0.040, 0.198]


def mix_norm_cdf(x, weights, means, covars):
    mcdf = 0.0
    for i in range(len(weights)):
        mcdf += weights[i] * norm.cdf(x, loc=means[i], scale=covars[i])
    return mcdf


print(mix_norm_cdf(50, weights, means, covars))

输出

0.442351546658755

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-27
    • 2017-12-04
    • 2014-06-29
    • 2016-12-29
    • 1970-01-01
    • 2014-03-27
    • 2021-12-28
    • 2021-09-30
    相关资源
    最近更新 更多