I am able to apply multiple measurements (2) to the same qubit system. However, I would like to get the counts right after each measurement is executed. I realize that the counts should be the same after every measurement of the same system. I would just like to see empirical proof of the so-called "repeated measurement principle" without any evolution of the system. I attempted to write a program which would achieve this, but had no success:
import time
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute, IBMQ, Aer
from qiskit.backends.ibmq import least_busy
from qiskit import compile as q_compile
counter = 0
def generate_circuits(num_q):
# Create a Quantum Register with 1 qubits.
q = QuantumRegister(num_q, 'q')
# Create a Classical Register with 1 bits.
c = ClassicalRegister(num_q, 'c')
# Create a Quantum Circuit
qc = QuantumCircuit(q, c)
if counter == 0:
# Add a H gate on qubit 0, putting this qubit in superposition.
qc.h(q[0])
# Add a Measure gate to see the state.
qc.measure(q, c)
qc.barrier(q)
return qc
else:
qc.measure(q, c)
return qc
backend = Aer.get_backend('qasm_simulator')
qc_gen = generate_circuits(1)
qobj = q_compile(qc_gen, backend, shots=1000)
job = backend.run(qobj)
result = job.result()
data = result.get_counts(qc_gen)
print(data)
counter += 1
qobj = q_compile(qc_gen, backend, shots=1000)
job = backend.run(qobj)
result = job.result()
data = result.get_counts(qc_gen)
print(data)
which returned:
{'0': 489, '1': 511}
{'0': 491, '1': 509}
Any ideas?
measure(q[0],c[j])
for the jth measurement ofq[0]
. $\endgroup$