TuringLang / AdvancedHMC.jl

Robust, modular and efficient implementation of advanced Hamiltonian Monte Carlo algorithms
https://turinglang.org/AdvancedHMC.jl/
MIT License
228 stars 39 forks source link

Unify the Euclidean metric types #288

Open sethaxen opened 2 years ago

sethaxen commented 2 years ago

We need 4 things from a Euclidean metric:

Current this is handled by 3 different types:

However, a user may want to initialize with a diagonal metric adapt a dense metric or vice versa. Assuming we only support metrics for which an AbstractMatrix representation is available, it seems like it would be preferable to instead have a single EuclideanMetric type that stores the matrices M⁻¹ and W (UniformScaling for UnitEuclideanMetric) and then have the convenient aliases:

const ScalarEuclideanMetric = EuclideanMetric{<:UniformScaling}
const DiagonalEuclideanMetric = EuclideanMetric{<:Diagonal}

for dispatch.

This would also eliminate the need for a custom metric type whenever a user wants to use a different matrix type for the metric for which a more efficient W is available then the Cholesky factor, see e.g. #277, #282