Hamiltonian MCMC Sampler

class sampyl.Hamiltonian(logp, start, step_size=1, n_steps=5, **kwargs)
sample(num, burn=0, thin=1, n_chains=1, progress_bar=True)

Sample from \(P(X)\)

Parameters:
  • numint. Number of samples to draw from \(P(X)\).
  • burn – (optional) int. Number of samples to discard from the beginning of the chain.
  • thin – (optional) float. Thin the samples by this factor.
  • n_chains – (optional) int. Number of chains to return. Each chain is given its own process and the OS decides how to distribute the processes.
  • progress_bar – (optional) boolean. Show the progress bar, default = True.
Returns:

Record array with fields taken from arguments of logp function.

step()

This is what you define to create the sampler. Requires that a state object is returned.