Processing math: 100%

qml.resource.estimate_error

estimate_error(coeffs, variances=None, shots=1000)[source]

Estimate the error in computing an expectation value with a given number of measurements.

See also estimate_shots().

Parameters
  • coeffs (list[tensor_like]) – list of coefficient groups

  • variances (list[float]) – variances of the Pauli word groups

  • shots (int) – the number of measurements

Returns

target error in computing the expectation value

Return type

float

Example

>>> coeffs = [np.array([-0.32707061, 0.7896887]), np.array([0.18121046])]
>>> qml.resource.estimate_error(coeffs, shots=100000)
0.00327597

An estimation for the error ϵ in predicting the expectation value of an observable H=iAi with A=jcjOj representing a linear combination of Pauli words can be obtained following Eq. (34) of [PRX Quantum 2, 040320 (2021)] as

ϵ=iVar(Ai)M,

with M and Var(A) denoting the number of measurements and the variance in computing A, respectively. It has been shown in Eq. (10) of [arXiv:2201.01471v3] that the variances can be computed from the covariances between the Pauli words as

Var(Ai)=jkcjckCov(Oj,Ok),

where

Cov(Oj,Ok)=OjOkOjOk.

The values of Cov(Oj,Ok) are not known a priori and should be either computed from affordable classical methods, such as the configuration interaction with singles and doubles (CISD), or approximated with other methods. If the variances are not provided to the function as input, they will be approximated following Eqs. (6-7) of [Phys. Rev. Research 4, 033154, 2022] by assuming Cov(Oj,Ok)=0 for jk and using Var(Oi)1 from

Var(Oi)=O2iOi2=1Oi2.

This approximation gives

ϵijc2ijM,

where i and j run over the observable groups and the Pauli words inside the group, respectively.