qiskit.opflow.state_fns.CVaRMeasurement.eval_variance¶
-
CVaRMeasurement.
eval_variance
(front=None)[source]¶ Given the energies of each sampled measurement outcome (H_i) as well as the sampling probability of each measurement outcome (p_i, we can compute the variance of the CVaR estimator as H_j^2 + 1/α * (sum_i<j p_i*(H_i^2 - H_j^2)). This follows from the definition that Var[X] = E[X^2] - E[X]^2. In this case, X = E[<bi|H|bi>], where H is the diagonal observable and bi corresponds to measurement outcome i. Given this, E[X^2] = E[<bi|H|bi>^2]
- Parameters
front (
Union
[str
,dict
,ndarray
,OperatorBase
,None
]) – A StateFn or primitive which specifies the results of evaluating a quantum state.- Return type
complex
- Returns
- The Var[CVaR] of the diagonal observable specified by self.primitive
and the sampled quantum state described by the inputs (energies, probabilities). For index j (described above), the CVaR is computed as H_j^2 + 1/α*(sum_i<j p_i*(H_i^2 - H_j^2))