openfermion.linalg.variance

Compute variance of operator with a state.

operator scipy.sparse.spmatrix or scipy.sparse.linalg.LinearOperator

The operator whose expectation value is desired.

state numpy.ndarray or scipy.sparse.spmatrix

A numpy array representing a pure state or a sparse matrix representing a density matrix.

A complex number giving the variance.

ValueError Input state has invalid format.