iqm.error_reduction_tools.utils.general_utils.expectation_from_counts#
- iqm.error_reduction_tools.utils.general_utils.expectation_from_counts(counts, pauli_string=None)#
Calculate expectation value of a Pauli string from measurement counts.
- Parameters:
- Return type:
Note
Bitstrings and Pauli strings both follow the same ordering (typically little-endian). This is consistent with
qiskit.result.sampled_expectation_value.Example
>>> counts = {"01": 10} >>> pauli_string = "ZI" >>> expectation_from_counts(counts, pauli_string) 1.0