qiskit.aqua.operators.expectations.ExpectationBase¶

class
ExpectationBase
[código fonte]¶ A base for Expectation value converters. Expectations are converters which enable the computation of the expectation value of an Observable with respect to some state function. They traverse an Operator tree, replacing OperatorStateFn measurements with equivalent measurements which are more amenable to computation on quantum or classical hardware. For example, if one would like to measure the expectation value of an Operator
o
expressed as a sum of Paulis with respect to some state function, but only has access to diagonal measurements on Quantum hardware, we can create a measurement ~StateFn(o), use aPauliExpectation
to convert it to a diagonal measurement and circuit prerotations to a append to the state, and sample this circuit on Quantum hardware with a CircuitSampler. All in all, this would be:my_sampler.convert(my_expect.convert(~StateFn(o)) @ my_state).eval()
.
__init__
()¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
()Initialize self.
compute_variance
(exp_op)Compute the variance of the expectation estimator.
convert
(operator)Accept an Operator and return a new Operator with the measurements replaced by alternate methods to compute the expectation value.

abstract
compute_variance
(exp_op)[código fonte]¶ Compute the variance of the expectation estimator.
 Parâmetros
exp_op (
OperatorBase
) – The full expectation value Operator after sampling. Tipo de retorno
Union
[list
,float
,complex
,ndarray
] Retorna
The variances or lists thereof (if exp_op contains ListOps) of the expectation value estimation.

abstract
convert
(operator)[código fonte]¶ Accept an Operator and return a new Operator with the measurements replaced by alternate methods to compute the expectation value.
 Parâmetros
operator (
OperatorBase
) – The operator to convert. Tipo de retorno
OperatorBase
 Retorna
The converted operator.
