qiskit-documentation/docs/api/qiskit/0.43/qiskit.opflow.expectations....

67 lines
3.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: PauliExpectation
description: API reference for qiskit.opflow.expectations.PauliExpectation
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.opflow.expectations.PauliExpectation
---
# PauliExpectation
<Class id="qiskit.opflow.expectations.PauliExpectation" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.24/qiskit/opflow/expectations/pauli_expectation.py" signature="PauliExpectation(group_paulis=True)" modifiers="class">
Bases: [`ExpectationBase`](qiskit.opflow.expectations.ExpectationBase "qiskit.opflow.expectations.expectation_base.ExpectationBase")
Deprecated: 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. Optionally groups the Paulis with the same post-rotations (those that commute with one another, or form Abelian groups) into single measurements to reduce circuit execution overhead.
<Admonition title="Deprecated since version 0.24.0" type="danger">
The class `qiskit.opflow.expectations.pauli_expectation.PauliExpectation` is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. For code migration guidelines, visit [https://qisk.it/opflow\_migration](https://qisk.it/opflow_migration).
</Admonition>
**Parameters**
**group\_paulis** (*bool*) Whether to group the Pauli measurements into commuting sums, which all have the same diagonalizing circuit.
## Methods Defined Here
<span id="qiskit-opflow-expectations-pauliexpectation-compute-variance" />
### compute\_variance
<Function id="qiskit.opflow.expectations.PauliExpectation.compute_variance" signature="PauliExpectation.compute_variance(exp_op)">
Compute the variance of the expectation estimator.
**Parameters**
**exp\_op** ([*OperatorBase*](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 | float | [*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v1.25)")
</Function>
<span id="qiskit-opflow-expectations-pauliexpectation-convert" />
### convert
<Function id="qiskit.opflow.expectations.PauliExpectation.convert" signature="PauliExpectation.convert(operator)">
Accepts an Operator and returns a new Operator with the Pauli measurements replaced by diagonal Pauli post-rotation based measurements so they can be evaluated by sampling and averaging.
**Parameters**
**operator** ([*OperatorBase*](qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")) The operator to convert.
**Returns**
The converted operator.
**Return type**
[*OperatorBase*](qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")
</Function>
</Class>