class netket.sampler.MetropolisHamiltonian(hilbert, hamiltonian, *args, **kwargs)[source]

Sampling based on the off-diagonal elements of a Hamiltonian (or a generic Operator). In this case, the transition matrix is taken to be:

\[T( \mathbf{s} \rightarrow \mathbf{s}^\prime) = \frac{1}{\mathcal{N}(\mathbf{s})}\theta(|H_{\mathbf{s},\mathbf{s}^\prime}|),\]

where \(\theta(x)\) is the Heaviside step function, and \(\mathcal{N}(\mathbf{s})\) is a state-dependent normalization. The effect of this transition probability is then to connect (with uniform probability) a given state \(\mathbf{s}\) to all those states \(\mathbf{s}^\prime\) for which the Hamiltonian has finite matrix elements. Notice that this sampler preserves by construction all the symmetries of the Hamiltonian. This is in generally not true for the local samplers instead.

This sampler only works on the CPU. To use the Hamiltonian smapler with GPUs, you should use netket.sampler.MetropolisHamiltonianNumpy

  • machine – A machine \(\Psi(s)\) used for the sampling. The probability distribution being sampled from is \(F(\Psi(s))\), where the function \(F(X)\), is arbitrary, by default \(F(X)=|X|^2\).

  • hamiltonian – The operator used to perform off-diagonal transition.

  • n_chains – The number of Markov Chain to be run in parallel on a single process.

  • sweep_size – The number of exchanges that compose a single sweep. If None, sweep_size is equal to the number of degrees of freedom (n_visible).


Sampling from a RBM machine in a 1D lattice of spin 1/2

>>> import netket as nk
>>> g=nk.graph.Hypercube(length=10,n_dim=2,pbc=True)
>>> hi=nk.hilbert.Spin(s=0.5,graph=g)
>>> # RBM Spin Machine
>>> ma = nk.machine.RbmSpin(alpha=1, hilbert=hi)
>>> # Transverse-field Ising Hamiltonian
>>> ha = nk.operator.Ising(hilbert=hi, h=1.0)
>>> # Construct a MetropolisHamiltonian Sampler
>>> sa = nk.sampler.MetropolisHamiltonian(machine=ma,hamiltonian=ha)
Return type



Initialize self. See help(type(self)) for accurate signature.