Skip to content

Extend logpdf messages with importance distributions #252

@ismailsenoz

Description

@ismailsenoz

Sometimes we send pdf messages and need to evaluate the expectation statistics of these un-normalized pdf messages. Under the assumption that these messages are integrable, we resort to importance sampling to compute the expectations. Consequently, a user might need to define a function
function ReactiveMP.mean_var(p::ReactiveMP.ContinuousMultivariateLogPdf) of this sort. Augmenting the ReactiveMP.ContinuousUnivariateLogPdf with an additional importance distribution would allow us to write a generic function to compute the expectation statistics. Very roughly, the function would look like this.

function ReactiveMP.computeExpectation(T::Function, p::ReactiveMP.ContinuousMultivariateLogPdf)
    nsamples               = p.no_samples
    importancedistribution = p.importance_distribution
    modifiedpdf            = (x) -> exp(p.logdpdf(x) - importancedistribution.logpdf(x))
    samples                = rand(importancedistribution, nsamples)
    weights                = computeWeights(modifiedpdf, samples)
    statistics             = sum(weights .* T.(samples))
    
    return statistics
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions