【问题标题】:Probabilistic programming : reifying distributions and stuff?概率编程:具体化分布和东西?
【发布时间】:2021-08-07 04:15:12
【问题描述】:

ProbLog 和/或 prolog/cplint 是否支持使用分布和具体化分布、条件/观察等,例如 WebPPL 中的以下示例。

如果是,你是怎么做到的?

/我知道 cplint 支持的可能是发行版,但是具体化?/

// sampling function, condition() acts 
// like filter i.e. the match is excluded from sampling result
var test = function() {
    var a = flip() //Bernoulli
    var b = flip()
    condition(a||b)
    return {a:a,b:b}
}

//reifying a distribution
var abc = Infer({method: 'rejection', samples:1000}, test)
abc

$ webppl test2.wppl 
Marginal:
    {"a":false,"b":true} : 0.337
    {"a":true,"b":false} : 0.332
    {"a":true,"b":true} : 0.331

【问题讨论】:

    标签: prolog probability problog webppl


    【解决方案1】:

    是的。 ProbLog 和 cplint 都支持条件分布(观察)。考虑以下程序:

    0.5::a.
    0.5::b.
    
    q_a_and_b:- a,b.
    q_or:- a.
    q_or:- b.
    

    在cplint中,你可以查询给定的证据:

    ?- prob(q_a_and_b,q_or,Prob).
    Prob = 0.33.
    

    ProbLog 也是如此(您需要直接在程序中添加查询和证据)。前面的查询可以理解为:“鉴于观察到q_orq_a_and_b 为真的概率是多少?”。该解决方案采用精确推理。在 cplint 中,您也可以使用近似推理(使用 MCINTYRE 模块),但对于此示例程序,不需要。

    【讨论】:

    • 谢谢,是否可以混合和匹配,即从边缘化/采样分布到“精确接口”分布并返回到同一个程序中...
    • 在 Problog 你会如何做 Gaussian 和其他精确的 dist ?你可以通过 python problog 以某种方式利用 numpy 或者这只能用于采样
    • 如果您想使用连续随机变量(或离散和连续),您应该使用 cplint od HAL-ProbLog(也称为 DC-ProbLog)。无论如何,您可以根据需要使用精确推理和近似推理:只需编写一个调用精确推理然后近似推理的规则。可以使用 HAL-ProbLog(或 DC-Problog)执行对连续随机变量的精确推断。在 cplint 中,您只有基于采样(拒绝或 MCMC)的近似推断。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-30
    • 1970-01-01
    相关资源
    最近更新 更多