59 lines
2.7 KiB
Plaintext
59 lines
2.7 KiB
Plaintext
---
|
||
title: ExpectationBase (v0.31)
|
||
description: API reference for qiskit.aqua.operators.expectations.ExpectationBase in qiskit v0.31
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.aqua.operators.expectations.ExpectationBase
|
||
---
|
||
|
||
# ExpectationBase
|
||
|
||
<Class id="qiskit.aqua.operators.expectations.ExpectationBase" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/aqua/operators/expectations/expectation_base.py" signature="ExpectationBase" modifiers="class">
|
||
Bases: `qiskit.aqua.operators.converters.converter_base.ConverterBase`
|
||
|
||
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 a `PauliExpectation` to convert it to a diagonal measurement and circuit pre-rotations 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()`.
|
||
|
||
## Methods
|
||
|
||
<span id="qiskit-aqua-operators-expectations-expectationbase-compute-variance" />
|
||
|
||
### compute\_variance
|
||
|
||
<Function id="qiskit.aqua.operators.expectations.ExpectationBase.compute_variance" signature="ExpectationBase.compute_variance(exp_op)" modifiers="abstract">
|
||
Compute the variance of the expectation estimator.
|
||
|
||
**Parameters**
|
||
|
||
**exp\_op** (`OperatorBase`) – The full expectation value Operator after sampling.
|
||
|
||
**Return type**
|
||
|
||
`Union`\[`list`, `float`, `complex`, `ndarray`]
|
||
|
||
**Returns**
|
||
|
||
The variances or lists thereof (if exp\_op contains ListOps) of the expectation value estimation.
|
||
</Function>
|
||
|
||
<span id="qiskit-aqua-operators-expectations-expectationbase-convert" />
|
||
|
||
### convert
|
||
|
||
<Function id="qiskit.aqua.operators.expectations.ExpectationBase.convert" signature="ExpectationBase.convert(operator)" modifiers="abstract">
|
||
Accept an Operator and return a new Operator with the measurements replaced by alternate methods to compute the expectation value.
|
||
|
||
**Parameters**
|
||
|
||
**operator** (`OperatorBase`) – The operator to convert.
|
||
|
||
**Return type**
|
||
|
||
`OperatorBase`
|
||
|
||
**Returns**
|
||
|
||
The converted operator.
|
||
</Function>
|
||
</Class>
|
||
|