41 lines
4.8 KiB
Plaintext
41 lines
4.8 KiB
Plaintext
---
|
||
title: expectations
|
||
description: API reference for qiskit.aqua.operators.expectations
|
||
in_page_toc_min_heading_level: 2
|
||
python_api_type: module
|
||
python_api_name: qiskit.aqua.operators.expectations
|
||
---
|
||
|
||
<span id="module-qiskit.aqua.operators.expectations" />
|
||
|
||
<span id="qiskit-aqua-operators-expectations" />
|
||
|
||
<span id="expectations-qiskit-aqua-operators-expectations" />
|
||
|
||
# Expectations
|
||
|
||
<span id="module-qiskit.aqua.operators.expectations" />
|
||
|
||
`qiskit.aqua.operators.expectations`
|
||
|
||
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`](qiskit.aqua.operators.state_fns.OperatorStateFn "qiskit.aqua.operators.state_fns.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`](qiskit.aqua.operators.expectations.PauliExpectation "qiskit.aqua.operators.expectations.PauliExpectation") to convert it to a diagonal measurement and circuit pre-rotations to append to the state, and sample this circuit on Quantum hardware with a [`CircuitSampler`](qiskit.aqua.operators.converters.CircuitSampler "qiskit.aqua.operators.converters.CircuitSampler"). All in all, this would be: `my_sampler.convert(my_expect.convert(~StateFn(o)) @ my_state).eval()`.
|
||
|
||
# Expectation Base Class
|
||
|
||
The ExpectationBase class gives an interface for algorithms to ask for Expectations as execution settings. For example, if an algorithm contains an expectation value step within it, such as [`VQE`](qiskit.aqua.algorithms.VQE "qiskit.aqua.algorithms.VQE"), the algorithm can give the opportunity for the user to pass an ExpectationBase of their choice to be used in that expectation value step.
|
||
|
||
| | |
|
||
| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
|
||
| [`ExpectationBase`](qiskit.aqua.operators.expectations.ExpectationBase "qiskit.aqua.operators.expectations.ExpectationBase") | A base for Expectation value converters. |
|
||
|
||
# Expectations
|
||
|
||
| | |
|
||
| ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||
| [`ExpectationFactory`](qiskit.aqua.operators.expectations.ExpectationFactory "qiskit.aqua.operators.expectations.ExpectationFactory") | A factory class for convenient automatic selection of an Expectation based on the Operator to be converted and backend used to sample the expectation value. |
|
||
| [`AerPauliExpectation`](qiskit.aqua.operators.expectations.AerPauliExpectation "qiskit.aqua.operators.expectations.AerPauliExpectation") | An Expectation converter for using Aer’s operator snapshot to take expectations of quantum state circuits over Pauli observables. |
|
||
| [`MatrixExpectation`](qiskit.aqua.operators.expectations.MatrixExpectation "qiskit.aqua.operators.expectations.MatrixExpectation") | An Expectation converter which converts Operator measurements to be matrix-based so they can be evaluated by matrix multiplication. |
|
||
| [`PauliExpectation`](qiskit.aqua.operators.expectations.PauliExpectation "qiskit.aqua.operators.expectations.PauliExpectation") | An Expectation converter for Pauli-basis observables by changing Pauli measurements to a diagonal (\{Z, I}^n) basis and appending circuit post-rotations to the measured state function. |
|
||
| [`CVaRExpectation`](qiskit.aqua.operators.expectations.CVaRExpectation "qiskit.aqua.operators.expectations.CVaRExpectation") | Compute the Conditional Value at Risk (CVaR) expectation value. |
|
||
|