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

Extension for MarginalLogDensities.jl #2421

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

torfjelde
Copy link
Member

This PR adds an extension for MarginalLogDensities.jl, allowing one to call marginalize on a Model, resulting in a MarginalLogDensity from MarginalLogDensities.jl.

Example:

julia> using Turing, MarginalLogDensities

julia> @model function demo()
           x ~ Normal(0, 1)
           y ~ Normal(x, 1)
       end
demo (generic function with 2 methods)

julia> model = demo();

julia> # Marginalize out `x`.
       marginalized = marginalize(model, [@varname(x)]);

julia> # Compute the marginal log-density of `y = 0.0`.
       abs(marginalized([0.0]) - logpdf(Normal(0, 2), 0.0)) < 1e-1
true

Ref: #2398

@torfjelde
Copy link
Member Author

A bit uncertain if we should export this marginalize or hide it for now.

@torfjelde
Copy link
Member Author

torfjelde commented Dec 5, 2024

Note that this will fail until ElOceanografo/MarginalLogDensities.jl#36 has made its way to the public (i.e. v0.3.6). Not entirely certain why this hasn't happened yet (it is in the registry 😕 )

EDIT: ElOceanografo/MarginalLogDensities.jl#36 (comment)

@torfjelde
Copy link
Member Author

We need TuringLang/DynamicPPL.jl#738 to go through before this will work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant