You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add pre-conditioning matrix to Barker proposal (#731)
* Draft pre-conditioning matrix in Barker proposal.
This is a first draft of adding the pre-conditioning to the Barker
proposal. This follows Algorithms 4 and 5 in Appendix G of the original
Barker proposal paper. It's somewhat unclear from the paper, but the
separate step size that was already implemented serves as a global
scale for the normal distribution of the proposal. The function
`_compute_acceptance_probability` now takes in the transpose sqrt mass
matrix and the inverse, also it has been flattened to accomodate
the corresponding matrix multiplicatios.
* Fix typing of inverse_mass_matrix argument
Fix typing of mass matrix.
* Fix docstrings.
The original docstring of step_size was incorrect, there is no
sympletic integrator.
* Make test for Barker in test_sampling run again
We make this possible by adding an identity pre-conditining matrix,
which should make the test run in the same way as before.
* Add test to ensure correctness of precond matrix
We add a new test to barker.py to ensure that our implementation of
the preconditioning matrix is correct. We follow Appendix G in the
paper that mentions that algorithm 4 and 5 (which we implemented)
should be equivalent to rescaling the parameters and the logdensity
in a specific way. We implement both approaches when using the barker
proposal to infer the mean and sigma of a normal distribution. We
check that with two different random seeds the chains outputted are
equivalent up to some tolerance.
We also patch the original test in this file by adding an identity
mass matrix.
* Fix dimensionality of identity matrix
* Add missing mass matrix in missing tests.
* added option to transpose the matrix when scaling
option to transpose the mass_matrix_sqrt or inv_mass_matrix_sqrt was
necessary for the barker algorithm as far as I can tell. This has not
been propagated to the riemannian metric
* use the metric scaling function in barker
Here we use the new metric.scale function to perform the operations
required by the Barker proposal algorithm, instead of passing around
the mass_matrix_sqrt and inv_mass_matrix_sqrt directly. We also
make the `inverse_mass_matrix` argument optional to avoid breaking
the API.
* update test_sampling with barker api
the mass matrix is now an optional argument in barker.
* update test_barker so it works with metric.scale
* fix tests add trans to scale
* add trans argument to riemannian scaling
* no default
* Update barker.py
Make acceptance function metric agnostic
* Update test_barker.py
Add invariance test
* simplify logic to remove _barker_sample_nd
* fix bug so now everything is tree_mapped in barker
* fix test to not use _barker_sample_nd
* Update blackjax/mcmc/metrics.py
make inv and trans required kwarg with type bool in metric.scale
Co-authored-by: Junpeng Lao <[email protected]>
* Update blackjax/mcmc/metrics.py
lax.cond might not be needed in metric.scale as inv and trans are static kwarg
Co-authored-by: Junpeng Lao <[email protected]>
* propagate changes of inv, trans as required kwarg
* fix test metrics
---------
Co-authored-by: Adrien Corenflos <[email protected]>
Co-authored-by: Junpeng Lao <[email protected]>
0 commit comments