Using distribution collections¶
When you mitigate over multiple circuits the return object is a mthree.classes.QuasiCollection
from qiskit import *
from qiskit_ibm_runtime.fake_provider import FakeCasablancaV2
import mthree
qc = QuantumCircuit(6)
qc.reset(range(6))
qc.h(3)
qc.cx(3,1)
qc.cx(3,5)
qc.cx(1,0)
qc.cx(5,4)
qc.cx(1,2)
qc.measure_all()
backend = FakeCasablancaV2()
mit = mthree.M3Mitigation(backend)
mit.cals_from_system(range(6))
trans_qc = transpile([qc]*10, backend)
raw_counts = backend.run(trans_qc, shots=4000).result().get_counts()
quasis = mit.apply_correction(raw_counts, range(6), return_mitigation_overhead=True)
type(quasis)
mthree.classes.QuasiCollection
QuasiCollection
objects allow one to work with multiple distributions in the same manner as
a single one. E.g. we can get the mitigation overhead of the whole collection
quasis.mitigation_overhead
array([1.797272 , 1.8033769, 1.8011448, 1.795828 , 1.8056048, 1.808096 ,
1.7802615, 1.8000494, 1.8094052, 1.7957922], dtype=float32)
or compute expectation values and standard deviations over the full set:
quasis.expval_and_stddev('IZIZIZ')
[(0.043495744466781616, 0.02119712238221037),
(0.008683472871780396, 0.021233092807751937),
(0.037554770708084106, 0.021219948375164294),
(0.04385194182395935, 0.02118860547630793),
(0.03921884298324585, 0.021246204721316508),
(0.014586120843887329, 0.02126085649645868),
(0.02883651852607727, 0.021096572660324088),
(0.0319560170173645, 0.02121349437767348),
(0.016174226999282837, 0.021268552126708463),
(0.010800004005432129, 0.02118839417741873)]