netket.sampler.MetropolisExchange¶

class netket.sampler.MetropolisExchange(hilbert, *args, clusters=None, graph=None, d_max=1, **kwargs)[source]¶

This sampler acts locally only on two local degree of freedom \(s_i\) and \(s_j\), and proposes a new state: \(s_1 \dots s^\prime_i \dots s^\prime_j \dots s_N\), where in general \(s^\prime_i \neq s_i\) and \(s^\prime_j \neq s_j\). The sites \(i\) and \(j\) are also chosen to be within a maximum graph distance of \(d_{\mathrm{max}}\).

The transition probability associated to this sampler can be decomposed into two steps:

  1. A pair of indices \(i,j = 1\dots N\), and such that \(\mathrm{dist}(i,j) \leq d_{\mathrm{max}}\), is chosen with uniform probability.

  2. The sites are exchanged, i.e. \(s^\prime_i = s_j\) and \(s^\prime_j = s_i\).

Notice that this sampling method generates random permutations of the quantum numbers, thus global quantities such as the sum of the local quantum numbers are conserved during the sampling. This scheme should be used then only when sampling in a region where :math:`sum_i s_i = mathrm{constant} ` is needed, otherwise the sampling would be strongly not ergodic.

Parameters
  • hilbert – The hilbert space to sample

  • d_max – The maximum graph distance allowed for exchanges.

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

  • n_sweeps – The number of exchanges that compose a single sweep. If None, sweep_size is equal to the number of degrees of freedom being sampled (the size of the input vector s to the machine).

  • n_batches – The number of batches of the states to sample (default = 8)

  • machine_pow – The power to which the machine should be exponentiated to generate the pdf (default = 2).

  • dtype – The dtype of the statees sampled (default = np.float32).

Examples

Sampling from a RBM machine in a 1D lattice of spin 1/2, using nearest-neighbours exchanges.

>>> 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)
>>>
>>> # Construct a MetropolisExchange Sampler
>>> sa = nk.sampler.MetropolisExchange(machine=ma)
>>> print(sa.machine.hilbert.size)
100
Return type

MetropolisSampler

__init__(**kwargs)¶

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