qiskit-documentation/docs/api/qiskit/0.29/qiskit.ignis.mitigation.exp...

43 lines
2.4 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: expectation_value (v0.29)
description: API reference for qiskit.ignis.mitigation.expectation_value in qiskit v0.29
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.ignis.mitigation.expectation_value
---
<span id="qiskit-ignis-mitigation-expectation-value" />
# qiskit.ignis.mitigation.expectation\_value
<Function id="qiskit.ignis.mitigation.expectation_value" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-ignis/tree/stable/0.6/qiskit/ignis/mitigation/expval/utils.py" signature="expectation_value(counts, diagonal=None, qubits=None, clbits=None, meas_mitigator=None)">
Compute the expectation value of a diagonal operator from counts.
This computes the estimator of $\langle O \rangle = \mbox{Tr}[\rho. O]$, optionally with measurement error mitigation, of a diagonal observable $O = \sum_{x\in\{0, 1\}^n} O(x)|x\rangle\!\langle x|$.
**Parameters**
* **counts** counts object
* **diagonal** Optional, the vector of diagonal values for summing the expectation value. If `None` the the default value is $[1, -1]^\otimes n$.
* **qubits** Optional, the measured physical qubits the count bitstrings correspond to. If None qubits are assumed to be $[0, ..., n-1]$.
* **clbits** Optional, if not None marginalize counts to the specified bits.
* **meas\_mitigator** Optional, a measurement mitigator to apply mitigation.
**Returns**
the expectation value and standard deviation.
**Return type**
(float, float)
## Additional Information:
The diagonal observable $O$ is input using the `diagonal` kwarg as a list or Numpy array $[O(0), ..., O(2^n -1)]$. If no diagonal is specified the diagonal of the Pauli operator $O = \mbox{diag}(Z^{\otimes n}) = [1, -1]^{\otimes n}$ is used.
The `clbits` kwarg is used to marginalize the input counts dictionary over the specified bit-values, and the `qubits` kwarg is used to specify which physical qubits these bit-values correspond to as `circuit.measure(qubits, clbits)`.
For calibrating a expval measurement error mitigator for the `meas_mitigator` kwarg see [`qiskit.ignis.mitigation.expval_meas_mitigator_circuits()`](qiskit.ignis.mitigation.expval_meas_mitigator_circuits "qiskit.ignis.mitigation.expval_meas_mitigator_circuits") and [`qiskit.ignis.mitigation.ExpvalMeasMitigatorFitter`](qiskit.ignis.mitigation.ExpvalMeasMitigatorFitter "qiskit.ignis.mitigation.ExpvalMeasMitigatorFitter").
</Function>