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

How to get the "standard" logdensity? #144

Open
gdalle opened this issue Aug 20, 2021 · 1 comment
Open

How to get the "standard" logdensity? #144

gdalle opened this issue Aug 20, 2021 · 1 comment

Comments

@gdalle
Copy link
Collaborator

gdalle commented Aug 20, 2021

Sometimes I am actually bothered by the fact that the base measure of, say, Normal() is not the Lebesgue measure. In case I need the traditional logdensity, what do I do?

@cscherrer
Copy link
Collaborator

This is a great point, and something we definitely need to improve.

I think currently you can do something like

  1. Get the density relative to the base measure you want
  2. Integrate this with respect to the base measure to get the result

It's generally better to do this in log space, so you end up with

julia>= log𝒹(Normal(), Lebesgue(ℝ))
MeasureTheory.Density{Normal{(), Tuple{}}, Lebesgue{ℝ}, Val{true}}(Normal(), Lebesgue(ℝ), Val{true}())

julia> μ = ∫exp(ℓ, Lebesgue(ℝ))
DensityMeasure (Density{Normal{(), Tuple{}}, Lebesgue{ℝ}, Val{true}}(Normal(), Lebesgue(ℝ), Val{true}()), Lebesgue(ℝ); log = true)

There are obvious problems with this:

  • It takes more effort than it should
  • It's very notation-heavy
  • The result is still a normal distribution, but it's unrecognizable

I think an analogy can help us think about this in the right way. Entirely outside of MeasureTheory, say you want to represent a vector space. There are some things you can do very abstractly, but for others you need to specify a basis. Then

  1. Choice of preferred basis might depend strongly on what kind of operations you want to do
  2. We might want two vector spaces to be == if they have the same span, even if the bases are different

Currently the basemeasure for e.g. a Normal is fixed at 0.398942 * Lebesgue(ℝ), and changing it gives you something that's not a Normal. Maybe this shouldn't be the case?

BTW in case it's not clear, the motivation for our current choice of basemeasure is that of the terms in the logdensity with respect to Lebesgue measure, many of them don't depend on x, the point where we're evaluating the log-density. By removing these terms and changing the base measure accordingly, we can get something more efficient and composable.

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

No branches or pull requests

2 participants