Issue: it might open some opportunities if we allow a Gaussian distribution to be initialized with scipy.sparse.linalg.LinearOperator.
What I did:
update get_sqrtprec_from_sqrtcov in cuqi/distribution/_gaussian.py to accept aLinearOperator object as sqrtprec;
add check_if_conditional_from_attr in cuqi/utilities/_utilities.py, following @nabriis 's comment below;
check_if_conditional_from_attr is used in get_indirect_variables so that a Gaussian distribution initialized with LinearOperator is not detected as a conditional distribution (just a reminder: a LinearOperator is callable);
add unit test test_Gaussian_from_linear_operator_sqrtprec in tests/test_distribution.py
Some notes (please correct me if I'm wrong here):
For MCMC methods in general, we don't need logdet as it will be cancelled when evaluating the density function of the proposal and the current state;
In CUQIpy, we need logdet defined to compute logpdf: I think this is somehow unnecessary and the unnormalized version _logupdf should be enough in place of logpdf. But I have to admit that I'm not confident if this point still holds when it comes to Gibbs sampling. (This issue turned out to be an echo from the old days #16, as Nicolai pointed in the comments below)
In order to make a Gaussian distribution initialized with LinearOperator work with the current samplers in CUQIpy except ROTs, we need to set logdet to some value. It doesn't matter to what value it is set as it will be cancelled.
For RTOs, we don't evaluate logpdf, so we don't need to set logdet.
fixed #419
Issue: it might open some opportunities if we allow a Gaussian distribution to be initialized with
scipy.sparse.linalg.LinearOperator
.What I did:
get_sqrtprec_from_sqrtcov
incuqi/distribution/_gaussian.py
to accept aLinearOperator
object assqrtprec
;check_if_conditional_from_attr
incuqi/utilities/_utilities.py
, following @nabriis 's comment below;check_if_conditional_from_attr
is used inget_indirect_variables
so that aGaussian
distribution initialized withLinearOperator
is not detected as a conditional distribution (just a reminder: a LinearOperator is callable);test_Gaussian_from_linear_operator_sqrtprec
intests/test_distribution.py
Some notes (please correct me if I'm wrong here):
logdet
as it will be cancelled when evaluating the density function of the proposal and the current state;logdet
defined to computelogpdf
: I think this is somehow unnecessary and the unnormalized version_logupdf
should be enough in place oflogpdf
. But I have to admit that I'm not confident if this point still holds when it comes to Gibbs sampling. (This issue turned out to be an echo from the old days #16, as Nicolai pointed in the comments below)LinearOperator
work with the current samplers in CUQIpy except ROTs, we need to setlogdet
to some value. It doesn't matter to what value it is set as it will be cancelled.logpdf
, so we don't need to setlogdet
.