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.

qiskit.providers.aer.library.save_expectation_value_variance

save_expectation_value_variance(self, operator, qubits, label='expectation_value_variance', unnormalized=False, pershot=False, conditional=False)

GitHub

Save the expectation value of a Hermitian operator.

Parameters

  • operator (Pauli orSparsePauliOp orOperator) – a Hermitian operator.
  • qubits (list) – circuit qubits to apply instruction.
  • label (str) – the key for retrieving saved data from results.
  • unnormalized (bool) – If True return save the unnormalized accumulated or conditional accumulated expectation value and variance over all shot [Default: False].
  • pershot (bool) – if True save a list of expectation values and variances for each shot of the simulation rather than the average over all shots [Default: False].
  • conditional (bool) – if True save the data conditional on the current classical register values [Default: False].

Returns

with attached instruction.

Return type

QuantumCircuit

Raises

ExtensionError – if the input operator is invalid or not Hermitian.

Note

This method appends a SaveExpectationValueVariance instruction to the quantum circuit.

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