# Static HMC mass matrix/metric parameter

**URL:** <https://discourse.julialang.org/t/static-hmc-mass-matrix-metric-parameter/104926>\
**Category:** Performance\
**Tags:** turing, dynamichmc, mcmc\
**Created:** [October 13, 2023, 10:13am UTC](https://discourse.julialang.org/t/static-hmc-mass-matrix-metric-parameter/104926 "2023-10-13T10:13:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![caesoma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/caesoma/32/219651_2.png) [@caesoma](https://discourse.julialang.org/u/caesoma)\
**Post date:** [October 13, 2023, 10:13am UTC](https://discourse.julialang.org/t/static-hmc-mass-matrix-metric-parameter/104926/1 "2023-10-13T10:13:46Z")

</div>

I am running inference of a nonlinear model [as described here](https://discourse.julialang.org/t/tune-metropolis-hastings-normal-distribution-scale-parameters-and-algorithms-parameters-in-general/104925) it will run (albeit poorly) even with Metropolis-Hastings, and with acceptable results with NUTS and HMC with Dual averaging tuning of path length:

![nuHMCDA](https://global.discourse-cdn.com/julialang/original/3X/f/1/f1f202d3501fdf62b78c969de51ad8f7c1a03ef4.png)

With vanilla (fully manually-tuned parameters, static) HMC, however, despite using the step size (`step_size`) and number of leapfrogs (`n_steps`) extracted from its dual-averaging counterpart the chain doesn’t move:

![nuHMC](https://global.discourse-cdn.com/julialang/original/3X/5/c/5c7625a9f3ce6652a5069f66735baece2491912a.png)

The first thing I can think of that is missing for the vanilla HMC is the metric, mass matrix component of the momentum proposal, but I wouldn’t exclude other causes for this failure unless there’s an extreme mismatch between the default covariance matrix and the problem metric.

So the questions are:

1. **Is it possible to specify the mass matrix for the `HMC` method?**
2. **In case that doesn’t solve it, what else could be causing the complete breakdown of inference?**
