• Docs >
  • Using distribution collections
Shortcuts

Using distribution collectionsΒΆ

When you mitigate over multiple circuits the return object is a mthree.classes.QuasiCollection

from qiskit import *
from qiskit.test.mock.backends import FakeCasablanca
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 = FakeCasablanca()
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.79571611, 1.79250751, 1.79798141, 1.64374076, 1.79562342,
       1.8043642 , 1.80914249, 1.79584364, 1.79479248, 1.79336136])

or compute expectation values and standard deviations over the full set:

quasis.expval_and_stddev('IZIZIZ')
[(0.015407867519066087, 0.021187945337714773),
 (0.002294953901330221, 0.021169007472542717),
 (-0.0015372339606497532, 0.021201305462566385),
 (0.020068258605182243, 0.020271536478537296),
 (0.013975796575476651, 0.02118739852194293),
 (0.01448102202009055, 0.02123890416897115),
 (0.02225396705224275, 0.021267007856694733),
 (0.0309780446944366, 0.021188697697464),
 (-0.02270021061921451, 0.02118249563094663),
 (0.021654952692052365, 0.021174048760913042)]