CUQI-DTU / CUQIpy

https://cuqi-dtu.github.io/CUQIpy/
Apache License 2.0
48 stars 9 forks source link

Joint distribution conditioning on out-of-bounds values #481

Closed nabriis closed 3 months ago

nabriis commented 3 months ago

Description

When working with joint distributions and evaluating log density or conditioning, we need to ensure the log density is consistant when evaluating.

This is currently NOT the case if we condition on a joint distribution where some densities have the possibility of returning "-inf" when the value is out-of-bounds.

Example to reproduce

TBD

import numpy as np
import cuqi

joint = cuqi.distribution.JointDistribution(
            cuqi.distribution.Uniform(0, 10, name="d"),
            cuqi.distribution.Uniform(0, 5, name="s"),
            cuqi.distribution.Gaussian(np.zeros(8), lambda d: d, name="x"),
            cuqi.distribution.Gaussian(
                mean=cuqi.testproblem.Deconvolution1D(dim=8).model,
                cov=lambda s: s,
                name="y"
            )
        )

print(joint.logd(d=11, s=2, x=np.zeros(8), y=cuqi.testproblem.Deconvolution1D(dim=8).data))

print(joint(d=10, s=2, y=cuqi.testproblem.Deconvolution1D(dim=8).data).logd(x=np.zeros(8)))

returns

[-inf]
[-30.61073851]

should return both [-inf]