Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend logpdf messages with importance distributions #252

Open
ismailsenoz opened this issue Jan 30, 2023 · 0 comments
Open

Extend logpdf messages with importance distributions #252

ismailsenoz opened this issue Jan 30, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ismailsenoz
Copy link
Contributor

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
@ismailsenoz ismailsenoz added enhancement New feature or request good first issue Good for newcomers labels Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant