Main Content

**Class: **HamiltonianSampler

Tune Hamiltonian Monte Carlo (HMC) sampler

`tunedSmp = tuneSampler(smp)`

[tunedSmp,tuningInfo]
= tuneSampler(smp)

[tunedSmp,tuningInfo]
= tuneSampler(___,Name,Value)

returns
a tuned Hamiltonian Monte Carlo (HMC) sampler.`tunedSmp`

= tuneSampler(`smp`

)

First, `tuneSampler`

tunes the mass vector of
the HMC sampler `smp`

. Then, it tunes the step
size and number of steps of the leapfrog integrations to achieve a
certain target acceptance ratio.

You can use the tuned sampler to create Markov chains using
the `drawSamples`

method.

`[`

returns additional
tuning information in `tunedSmp`

,`tuningInfo`

]
= tuneSampler(`smp`

)`tuningInfo`

.

`[`

specifies
additional options using one or more name-value pair arguments. Specify
name-value pair arguments after all other input arguments. `tunedSmp`

,`tuningInfo`

]
= tuneSampler(___,`Name,Value`

)

After creating an HMC sampler using the

`hmcSampler`

function, you can compute MAP (maximum-a-posteriori) point estimates, tune the sampler, draw samples, and check convergence diagnostics using the methods of the`HamiltonianSampler`

class. For an example of this workflow, see Bayesian Linear Regression Using Hamiltonian Monte Carlo.