# netket.sampler.rules.MetropolisRule#

class netket.sampler.rules.MetropolisRule#

Bases: abc.ABC

Base class for transition rules of Metropolis, such as Local, Exchange, Hamiltonian and several others.

Inheritance
Methods
init_state(sampler, machine, params, key)[source]#

Initialises the optional internal state of the Metropolis sampler transition rule.

The provided key is unique and does not need to be splitted.

It should return an immutable data structure.

Parameters
Return type
Returns

An optional state.

random_state(sampler, machine, params, sampler_state, key)[source]#

Generates a random state compatible with this rule.

By default this calls netket.hilbert.random.random_state().

Parameters

Returns a new object replacing the specified fields with new values.

reset(sampler, machine, params, sampler_state)[source]#

Resets the internal state of the Metropolis Sampler Transition Rule.

The default implementation returns the current rule_state without modifying it.

Parameters
Return type
Returns

A resetted, state of the rule. This returns the same type of rule_state() and might be None.

abstract transition(sampler, machine, params, sampler_state, key, σ)[source]#

Proposes a new configuration set of configurations $sigma’$ starting from the current chain configurations $$\sigma$$.

The new configurations $$\sigma'$$ should be a matrix with the same dimension as $$\sigma$$.

This function should return a tuple. where the first element are the new configurations $sigma’$ and the second element is either None or an array of length σ.shape[0] containing an optional log-correction factor. The correction factor should be non-zero when the transition rule is non-symmetrical.

Parameters
Return type
Returns

A tuple containing the new configurations $$\sigma'$$ and the optional vector of log corrections to the transition probability.