Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.
Important

IBM Quantum Platform is moving and this version will be sunset on July 1. To get started on the new platform, read the migration guide.

ExpectationFactory

class ExpectationFactory

GitHub

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.


Methods

build

static ExpectationFactory.build(operator, backend=None, include_custom=True)

A factory method for convenient automatic selection of an Expectation based on the Operator to be converted and backend used to sample the expectation value.

Parameters

  • operator (OperatorBase) – The Operator whose expectation value will be taken.
  • backend (Union[QuantumInstance, BaseBackend, None]) – The backend which will be used to sample the expectation value.
  • include_custom (bool) – Whether the factory will include the (Aer) specific custom expectations if their behavior against the backend might not be as expected. For instance when using Aer qasm_simulator with paulis the Aer snapshot can be used but the outcome lacks shot noise and hence does not intuitively behave overall as people might expect when choosing a qasm_simulator. It is however fast as long as the more state vector like behavior is acceptable.

Return type

ExpectationBase

Returns

The expectation algorithm which best fits the Operator and backend.

Raises

ValueError – If operator is not of a composition for which we know the best Expectation method.

Was this page helpful?
Report a bug or request content on GitHub.