Bengali
Languages
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

qiskit.opflow.expectations

Expectations (qiskit.opflow.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 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 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().

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, 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()

A base for Expectation value converters.

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()

An Expectation converter for using Aer's operator snapshot to take expectations of quantum state circuits over Pauli observables.

MatrixExpectation()

An Expectation converter which converts Operator measurements to be matrix-based so they can be evaluated by matrix multiplication.

PauliExpectation([group_paulis])

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(alpha[, expectation])

Compute the Conditional Value at Risk (CVaR) expectation value.