netket.stats.LocalEstimators#

class netket.stats.LocalEstimators[source]#

Bases: Pytree

Per-sample scalar estimators returned by local_estimators().

data has shape (n_chains, chain_len), one scalar local estimator value per sample.

The typical workflow is:

le = vstate.local_estimators(op)     # LocalEstimators, data: (n_chains, chain_len)
stats = le.to_stats()               # one-shot Stats
acc   = le.accumulate()             # start an OnlineStats accumulator

For online estimation across multiple sampling steps:

acc = None
for _ in range(n_steps):
    vstate.sample(n_discard_per_chain=0)
    le  = vstate.local_estimators(op)
    acc = le.accumulate(acc)         # updates or creates the accumulator
print(acc.get_stats())
Inheritance
Inheritance diagram of netket.stats.LocalEstimators
Attributes
data: Array#

Scalar local estimators with shape (n_chains, chain_len).

Methods
accumulate(old=None, *, max_lag=64)[source]#

Fold this batch into an online accumulator.

Parameters:
  • old – existing OnlineStats returned by a previous call, or None to start a fresh accumulator.

  • max_lag (int) – maximum ACF lag (only used when creating a fresh accumulator on the first call).

Returns:

Updated OnlineStats.

replace(**kwargs)[source]#

Replace the values of the fields of the object with the values of the keyword arguments. If the object is a dataclass, dataclasses.replace will be used. Otherwise, a new object will be created with the same type as the original object.

Return type:

TypeVar(P, bound= Pytree)

Parameters:
  • self (P)

  • kwargs (Any)

to_online_stats(*, max_lag=64)[source]#

Create an OnlineStats initialised with this batch.

Subsequent batches are folded in via acc = acc.update(new_le.data). Prefer accumulate() when writing the accumulation loop, as it handles both first and subsequent batches uniformly.

Parameters:

max_lag (int)

to_stats()[source]#

Compute summary statistics for this scalar local-estimator batch.

Equivalent to calling statistics() on self.data.

Return type:

Stats