How is inverse mass matrix computed during warmup?

Is the inverse mass matrix for HMC dynamically updated during the warmup window after each sample (Welford’s method), or is it calculated as the covariance matrix of the samples obtained during each window?

In each slow adaptation interval an empirical estimate of the (co)variances of the samples is computed using an online (Welford’s) algorithm, with the relevant statistics updated after each chain sample. The metric / mass matrix is however only updated to the (regularised) inverse of the covariance estimate using these statistics at the end of each slow adaptation interval.


How is the inverse of the covariance estimate regularised? Does regularising means limiting the values between 0 and 1.? What is the logic behind it?

The covariance is regularised (in the sense of Regularization (mathematics) - Wikipedia) towards an identity matrix, with the metric set to the inverse of a weighted sum of the empirical covariance estimate and the identity matrix, with weights depending on the number of samples in the adaptation interval: