-
Notifications
You must be signed in to change notification settings - Fork 47
Description
As instructed by the v0.7.0 release notes, I'm opening this issue to propose making rand_momentum part of the API.
Pathfinder.jl provides an approximation of a target distribution as a multivariate normal whose covariance matrix has a particular structure that can be exploited for efficient sampling. Pathfinder implements RankUpdateEuclideanMetric here, which allows this covariance matrix to be used as an (inverse) metric in AdvancedHMC (for usage examples, see https://mlcolab.github.io/Pathfinder.jl/v0.9/examples/initializing-hmc/#AdvancedHMC.jl)
The recent replacement of rand methods with internal rand_momentum methods require Pathfinder to implement this internal method to support integration with AdvancedHMC v0.7.0. It would be useful if rand_momentum was added to the public API to maker overloading it safer.
Alternatives:
- The proposal in Simplifying
Metrictypes by usingAbstractPDMat#34 to implement a singleMetricobject wrapping anAbstractPDMatwould also work, since Pathfinder's covariance matrix type is also anAbstractPDMat. RankUpdateEuclideanMetriccould live here in an extension instead of Pathfinder. However, since Pathfinder is more specific than this package, I think that makes less sense.- One could blend the two alternatives above by adding a
EuclideanMetricstruct that wraps anAbstractPDMatand allows any PDMat to be wrapped as a metric that implements the necessary interface. It would be good if this could support wrapping either the inverse metric or the metric itself. For the former, doing this efficiently and generically requires some package (maybe PDMats) implements something like asqrt_factfunction that returns a factorRsuch thatR' * Ris the PDMat andRimplementldiv!. This generalizes the Cholesky factorization for structured matrices for which a different square root factorization may be more efficient to compute and use than a Cholesky factorization.