iqm.error_reduction_tools.twirling.twirling_processors.untwirl_counts

Contents

iqm.error_reduction_tools.twirling.twirling_processors.untwirl_counts#

iqm.error_reduction_tools.twirling.twirling_processors.untwirl_counts(counts, rot_string)#

Apply untwirling to measurement counts.

Flips bits in measurement bitstrings according to a readout twirling string. For each qubit where the twirling operation was ‘X’, the corresponding measurement bit is flipped (0 ↔ 1).

Parameters:
  • counts (dict[str, int | float]) – Dictionary of measurement counts.

  • rot_string (list[str] | str | None) – List of readout twirling Pauli strings or a string (BIG endian, so the opposite of Qiskit’s little endian).

Returns:

Dictionary of untwirled counts.

Raises:

ValueError – If rot_string length doesn’t match number of qubits.

Return type:

dict[str, float]

Example

>>> counts = {'000': 10, '001': 5, '010': 3}
>>> rot_string = "XII"
>>> untwirl_counts(counts, rot_string)
{'001': 10, '000': 5, '011': 3}