I'm running simulations of my quantum circuit, which includes both parametrized variables and random numbers. The question I'm trying to solve is that for each parameterized variable, I will generate a set of quantum circuits, each element of which contains different random numbers. I'm hoping to run each quantum circuit in the set with 100 shots, then carry out some analyses on the counts. I'm not exactly sure how I can do that, here's part of the code I have:
from qiskit import IBMQ
provider = IBMQ.load_account()
sim = provider.backends.ibmq_qasm_simulator
backend = provider.get_backend('ibmq_qasm_simulator')
E = np.linspace(-5,5,10) # Parameters
circuits = []
nuni = 10. # Number of the circuits in each set.
for i in range(10):
circuitsi = []
for j in range (nuni):
circuit = QuantumCircuit(qrz,crz)
circuit = qc(E[i]) # qc is a function with both parameters and random numbers.
circuitsi.append(circuit)
circuits.append(circuitsi)
for i in range (len(circuits)):
for j in range (nuni):
circuits[i][j] = transpile(circuits[i][j],backend=backend)
for i in range (10):
job_manager = IBMQJobManager()
MExperiments = job_manager.run(circuits[i], backend=backend, shots = nshot)
results = MExperiments.results()
for j in range (nuni):
counts = results.get_counts(circuits[i][j])
My current code doesn't quite work, I'm wondering am I on the right track? How can I fix my code? Thanks a lot for your help:)
Update: My code works, but it takes a really long time to run. I'm still wondering if there's a simpler way to carry out the experiment? Thanks!