Skip to content

Understanding the AdvancedVI interface documented in the README #173

@weinstockj

Description

@weinstockj

I'm asking for a bit more clarity on the intended interface for AdvancedVI. For context, I'm a bit confused by the README, which includes the following example:

$$ \begin{aligned} x &\sim \mathrm{LogNormal}\left(\mu_x, \sigma_x^2\right) \\ y &\sim \mathcal{N}\left(\mu_y, \sigma_y^2\right), \end{aligned} $$

using LogDensityProblems

struct NormalLogNormal{MX,SX,MY,SY}
    μ_x::MX
    σ_x::SX
    μ_y::MY
    Σ_y::SY
end

function LogDensityProblems.logdensity(model::NormalLogNormal, θ)
    (; μ_x, σ_x, μ_y, Σ_y) = model
    return logpdf(LogNormal(μ_x, σ_x), θ[1]) + logpdf(MvNormal(μ_y, Σ_y), θ[2:end])
end

function LogDensityProblems.dimension(model::NormalLogNormal)
    return length(model.μ_y) + 1
end

function LogDensityProblems.capabilities(::Type{<:NormalLogNormal})
    return LogDensityProblems.LogDensityOrder{0}()
end

This all makes sense me: we define the intended probability model, and use the LogDensityProblems interface to provide helpful abstractions. I interpret the second parameter of the logdensity function to be where the "data" (in this case, [X, Y] ) would come in. I understand that X is a scalar and Y a vector.

However, later in the sample, I would expect that would simulate X and Y from the true generative model, and then attempt to infer the posterior of the parameters using AdvanedVI.optimize . However, that doesn't occur; the example instantiates the parameters, but does not simulate the 'data' from the true generative model.

Where in this example is the "data" actually fed in?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions