【问题标题】:Understand disaster model in PyMC了解 PyMC 中的灾难模型
【发布时间】:2014-11-18 12:18:33
【问题描述】:

我开始学习 PyMC 并努力理解第一个教程的示例。

disasters_array =   \
     np.array([ 4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6,
                   3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5,
                   2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0,
                   1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1,
                   0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2,
                   3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4,
                   0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1])
switchpoint = DiscreteUniform('switchpoint', lower=0, upper=110, doc='Switchpoint[year]')
early_mean = Exponential('early_mean', beta=1.)
late_mean = Exponential('late_mean', beta=1.)

我不明白为什么 early_mean 和 late_mean 被建模为随机变量,遵循速率 = 1 的指数分布。我的直觉是它们应该使用灾难数组和 switchpoint 变量进行确定性计算,例如

@deterministic(plot=False)
def early_mean(s=switchpoint):
    return sum(disasters_array[:(s-1)])/(s-1)

@deterministic(plot=False)
def late_mean(s=switchpoint):
    return sum(disasters_array[s:])/s

【问题讨论】:

    标签: pymc


    【解决方案1】:

    disasters_array 是泊松过程生成的数据,在此模型的假设下。 late_meanearly_mean 是与此过程相关的参数,具体取决于它们在时间序列中发生的时间。参数的真实值是未知的,因此它们被指定为随机变量。确定性对象仅适用于完全由其父项的值确定的节点。

    【讨论】:

      【解决方案2】:

      early_meanlate_mean 随机变量视为模型参数,将Exponential 视为这些参数的先验分布。在这里的模型版本中,确定性r 和可能性D 通过MCMC 采样导致early_meanlate_mean 的后验。

      【讨论】:

        猜你喜欢
        • 2017-05-14
        • 2011-03-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-04
        • 2017-02-24
        • 2019-07-11
        相关资源
        最近更新 更多