0

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

  • What’s the goal of your project? Why don’t you collect data for 1100 shots and then process and do plots for first 100, 200, $\cdots$, 1100 shots? – FDGod Feb 15 '24 at 01:00
  • @FDGod My goal is too see how shots affect output accuracy, hence measuring at the shot intervals. What Im doing is simulating a 16 qubit circuit with 100 shots and store the counts, simulate 16 qubit w/ 200 shots and store counts, etc.... – lookreachbrush Feb 15 '24 at 02:13
  • What do you mean that your output is big? For 16 qubits, you have $2^{16}$ basis states. – Martin Vesely Feb 15 '24 at 06:55

0 Answers0