netket.experimental.observable.VarianceObservable#

class netket.experimental.observable.VarianceObservable[source]#

Bases: AbstractObservable

Observable computing the variance of a quantum operator \(O\).

Inheritance
Inheritance diagram of netket.experimental.observable.VarianceObservable
__init__(operator, use_Oloc_squared=False)[source]#

Constructs the observable computing the variance of an arbitrary quantum operator \(O\) as:

\[\text{Var} = \frac{\langle \Psi | O^2 | \Psi \rangle}{\langle \Psi | \Psi \rangle} - \bigg( \frac{\langle \Psi | O | \Psi \rangle}{\langle \Psi | \Psi \rangle}\bigg)^2\]

It can compute the first term using either the estimator of the squared operator \(O^2\) (more precise but less efficient, since it requires the connected configurations and the matrix elements of \(O^2\)):

\[\text{Var} = \mathbb{E}_{\sigma \sim |\Psi(\sigma)|^2}\bigg[\frac{\langle \sigma | O^2 | \Psi \rangle}{\langle \sigma | \Psi \rangle}\bigg] - \bigg(\mathbb{E}_{\sigma \sim |\Psi(\sigma)|^2}\bigg[\frac{\langle \sigma | O | \Psi \rangle}{\langle \sigma | \Psi \rangle}\bigg]\bigg)^2.\]

or using the square modulus of the estimator of \(O\) (more noisy but more efficient):

\[\text{Var} = \mathbb{E}_{\sigma \sim |\Psi(\sigma)|^2}\bigg[\bigg(\frac{\langle \sigma | O | \Psi \rangle}{\langle \sigma | \Psi \rangle} - \mathbb{E}_{\sigma \sim |\Psi(\sigma)|^2}\bigg[\frac{\langle \sigma | O | \Psi \rangle}{\langle \sigma | \Psi \rangle}\bigg]\bigg)^2\bigg]\]

This VariationalOperator wraps an operator such that the gradient will not be computed with respect to the expectation value, but with respect to the variance.

Parameters:
  • operator (AbstractOperator) – The operator for which the variance is to be computed.

  • use_Oloc_squared (bool) – (Defaults False) if True, uses the fast estimator obtained by squaring the local estimator O_loc. If False, uses the straightforward estimator of (O@O)_loc which is quadratically more expensive. The fast estimator can sometimes lead to worse quality results.

Returns:

Observable computing the variance of operator.

Attributes
hilbert#

The hilbert space associated to this observable.

operator#

The operator for which the variance is to be computed.

operator_squared#

The squared of the operator for which the variance is to be computed. Depending on the flag use_Oloc_squared, this can be the operator using the local estimator of O^2 (False), or the one using the square modulus of the local estimator of O (True).

Methods