• 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.82864975, 1.836114  , 1.82514205, 1.81609206, 1.81970266,
       1.84039375, 1.83450865, 1.84131901, 1.8438245 , 1.84860439])

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

quasis.expval_and_stddev('IZIZIZ')
[(0.031889988863480934, 0.0213813572696495),
 (0.015011617234746644, 0.021424950437280973),
 (0.04824896769976994, 0.021360840652538716),
 (0.061388693858312804, 0.0213078158287979),
 (0.022039226978772364, 0.021328986472460783),
 (0.016174724824145892, 0.021449905290659235),
 (0.04468546755385622, 0.021415582206691722),
 (-0.017935556219499327, 0.021455296594062756),
 (0.012894241820297137, 0.021469888789445783),
 (0.03773860346902552, 0.021497699831827206)]