---
title: ExpectationBase (v0.46)
description: API reference for qiskit.opflow.expectations.ExpectationBase in qiskit v0.46
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/0.46/qiskit.opflow.expectations.ExpectationBase
---

# ExpectationBase

*class* `qiskit.opflow.expectations.ExpectationBase`

[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.46/qiskit/opflow/expectations/expectation_base.py)

Bases: [`ConverterBase`](/docs/api/qiskit/0.46/qiskit.opflow.converters.ConverterBase "qiskit.opflow.converters.converter_base.ConverterBase")

Deprecated: 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()`.

> **Deprecated since version 0.24.0**
>
> The class `qiskit.opflow.expectations.expectation_base.ExpectationBase` is deprecated as of qiskit-terra 0.24.0. It will be removed in the Qiskit 1.0 release. For code migration guidelines, visit [https://qisk.it/opflow\_migration](https://qisk.it/opflow_migration).

## Methods

### compute\_variance

*abstract* `compute_variance(exp_op)`

Compute the variance of the expectation estimator.

**Parameters**

**exp\_op** ([*OperatorBase*](/docs/api/qiskit/0.46/qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")) – The full expectation value Operator after sampling.

**Returns**

The variances or lists thereof (if exp\_op contains ListOps) of the expectation value estimation.

**Return type**

[list](https://docs.python.org/3/library/stdtypes.html#list) | [complex](https://docs.python.org/3/library/functions.html#complex) | [*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)

### convert

*abstract* `convert(operator)`

Accept an Operator and return a new Operator with the measurements replaced by alternate methods to compute the expectation value.

**Parameters**

**operator** ([*OperatorBase*](/docs/api/qiskit/0.46/qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")) – The operator to convert.

**Returns**

The converted operator.

**Return type**

[*OperatorBase*](/docs/api/qiskit/0.46/qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")
