Sample statistics module

The SampledObs class provides funcitonality to conveniently compute sample statistics.

Example:

Assuming that sampler is an instance of a sampler class and psi is a variational quantum state, the quantum geometric tensor \(S_{k,k'}=\langle(\partial_{\theta_k}\log\psi_\theta)^*\partial_{\theta_{k'}}\log\psi_\theta\rangle_c\) can be computed as

>>> s, logPsi, p = sampler.sample()
>>> grads = SampledObs( psi.gradients(s), p)
>>> S = grads.covar()
class jVMC.stats.SampledObs(observations=None, weights=None, estimator=None, params=None)

This class implements the computation of statistics from Monte Carlo or exact samples.

Initializer arguments:
  • observations: Observations \(O_n\) in the sample. This can be the value of an observable O(s_n) or the plain configuration s_n. The array must have a leading device dimension plus a batch dimension.

  • weights: Weights \(w_n\) associated with observation \(O_n\).

  • estimator: [optional] Function \(O(\theta, s)\) that computes an estimator parametrized by \(\theta\)

  • params: [optional] A set of parameters for the estimator function.

covar(other=None)

Returns the covariance.

Args:
  • other [optional]: Another instance of SampledObs.

covar_data(other=None)

Returns the covariance.

Args:
  • other [optional]: Another instance of SampledObs.

covar_var(other=None)

Returns the variance of the covariance.

Args:
  • other [optional]: Another instance of SampledObs.

mean(params=None)

Returns the mean.

mean_and_grad(psi, params)

Returns the mean and gradient of the given estimator.

select(ixs)

Returns a SampledObs for the data selection indicated by the given indices.

Args:
  • ixs: Indices of selected data.

subset(start=None, end=None, step=None)

Returns a SampledObs for a subset of the data.

Args:
  • start: Start sample index for subset selection

  • end: End sample index for subset selection

  • step: Sample index step for subset selection

transform(nonLinearFun=<function SampledObs.<lambda>>, linearFun=None)

Returns a SampledObs for the transformed data.

Args:
  • fun: A function.

var()

Returns the variance.