So, this is more of a code question rather than a theoretical question. I am working on project and I need to measure the output distributions at various shot intervals. I am currently using a simple while loop, but is there a way to simulate the circuit once AND measure at various intervals? Also, for some reason, my outputs seem way too big (they add up to 1 but its weird). Here is my code.
from qiskit import QuantumCircuit, Aer, execute
import json
from qiskit.visualization import circuit_drawer
qc = QuantumCircuit.from_qasm_file("dnn_16.qasm")
backend = Aer.get_backend("statevector_simulator")
x = 100
simple while loop to calculate
while x < 1100:
job = execute(qc, backend, shots=x)
result = job.result()
# statevector
statevector = result.get_statevector()
print(statevector)
# getting counts
counts = result.get_counts(qc)
with open('dnn_counts_' + str(x) + '_shots.json', 'w', encoding='utf-8') as f:
json.dump(counts, f, ensure_ascii=False, indent=4)
x += 100