Skip to content

MoG conditioning is wrong when a free dimension comes after a fixed one #2038

Closed

Description

@janfb

Bug description

MoG.condition gives wrong conditional means, variances and mixture weights when a free dimension (in dims_to_sample) has a higher index than a fixed dimension, and the components are correlated. It does not raise an error. The public sbi.analysis.ConditionedMDN uses this path (since #2026; before that, the copy in condition_mog had the same bug), so samples and densities from a conditioned MDN posterior are wrong in this case, also when passed to conditional_pairplot or conditional_corrcoeff.

Reproduction

One 2-D Gaussian component with correlation 0.8, conditioned on one dimension:

Free dimension sbi mean / variance Correct mean / variance
0 -0.90 / 0.36 -0.90 / 0.36
1 +1.50 / 1.00 +0.22 / 0.36

Cause

The code takes sub-blocks of the upper-triangular precision factor U and uses U_xx^T U_xx as the precision of the free dimensions and U_yy^T U_yy as the marginal precision of the fixed dimensions. That is exact only when all free dimensions come before all fixed dimensions. The existing test conditions only in that order.

Fix

Use the full precision P = U^T U: take P_xx from it, and compute the marginal precision of the fixed dimensions as the Schur complement P_yy - P_xy^T P_xx^{-1} P_xy. Add a test case where a free dimension comes after a fixed one, compared with the analytic conditional.

Activity

  1. added
    bug
    estimators
    on Oct 5, 2026
  2. self-assigned this
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugestimators

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions