Skip to content

Issue with affine transform and MvNormal #188

@ptiede

Description

@ptiede

Hi Chad,

I was just checking out the new version and noticed I was getting an inconsistent answer. Here is an MWE

using MeasureTheory
import Distributions as Dists
using LinearAlgebra

μ = zeros(2)
Σ = [1.0 0.0; 0.0 2.0]
Ω = [1.0 0.0; 0.0 0.5]

σC = cholesky(Σ)
ωC = cholesky(Ω)

dd = Dists.MvNormal(μ, Σ)

d1 = MvNormal{(:μ, :σ)}((μ=μ, σ=σC.L))
d2 = MvNormal{(:μ, :ω)}((μ=μ, ω=ωC.L))
d3 = Affine(AffineTransform((;μ, σ=σC.L)), Normal()^2)

# I expect this to give -0.5 log((2π)^2 * 2) ≈ -2.1845

logdensityof(dd, zeros(2)) # ≈ -2.1845
logdensityof(d1, zeros(2)) # ≈ -3.676
logdensityof(d2, zeros(2)) # ≈ -3.676
logdensityof(d3, zeros(2)) # ≈ -3.676

From my poking around, it looks like the log jacobian of the affine transform isn't being included in the density calculation, and inv(2pi) is being included twice: once in the basemeasure density and a second time in the proxy call.

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