Skip to content

Issue 06 — InverseWishart default-space log-partition uses mvtrigamma instead of logmvgamma #295

Description

@docxology

Issue 06 — InverseWishart default-space log-partition uses mvtrigamma instead of logmvgamma

Component: src/distributions/wishart_inverse.jl:323-327
Severity: MEDIUM (silent wrong value; mean-space only)
Type: Correctness

Summary

The DefaultParametersSpace (mean parameter space) log-partition of
InverseWishartFast is wrong:

getlogpartition(::DefaultParametersSpace, ::Type{InverseWishartFast}) = (θ) -> begin
    (ν, S) = unpack_parameters(InverseWishartFast, θ)
    p = first(size(S))
    return/ 2) * (p * log(2.0) - logdet(S)) + mvtrigamma(p, ν / 2)   # ← mvtrigamma!
end

mvtrigamma is the sum of trigammas — the correct object here is the log of the
multivariate gamma function, logmvgamma(p, ν/2). The Wishart sibling
(src/distributions/wishart.jl:297) uses logmvgamma correctly for the analogous
term. This looks like a copy-paste of the Fisher [1,1] entry (which legitimately
uses mvtrigamma).

Evidence / repro (Julia 1.12.6)

ν = 6.0; S = [3.0 0.5; 0.5 2.0]; p = 2
A_default = getlogpartition(DefaultParametersSpace(), InverseWishartFast)(θ)   # -0.2034
A_natural = getlogpartition(NaturalParametersSpace(), InverseWishartFast)(η)   #  0.4615
# hand value with logmvgamma: (ν/2)(p·ln2 − logdet S) + logmvgamma(p,ν/2) = 0.4615

The two parameter spaces return different values for the same log-partition; the
natural space and hand-derived values agree at 0.4615.

Impact

The mean-space log-partition of InverseWishartFast (used in ReactiveMP
NodeFunctionRule-type expectations and sqrt/mean-space computations) silently
returns a wrong value. Mathematically the two parametrizations must give the same
partition.

Proposed fix

return/ 2) * (p * log(2.0) - logdet(S)) + logmvgamma(p, ν / 2)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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