I had a question about obtaining the probability of a certain state from the histogram, still using this example, suppose there's a variable in my quantum circuit, it's values are stored in an 'np.linspace' array. This is the result obtained from one of the elements in that array: If I'm only interested in the probability of the '0010' state (0.831 here), is there a faster way I can get a list (or array) of the probability of '0010' using each element in my original linspace? I tried to incorporate a few commands (like job_sim and result_sim) into a function, but that doesn't work.
ps: The structure of my function looks something like this:
from qiskit import IBMQ provider = IBMQ.load_account() sim = provider.backends.ibmq_qasm_simulator def qc(Variable): qcz = QuantumCircuit(qrz,crz) ...... job_sim = execute(qcz, sim) result_sim = job_sim.result() counts = result_sim.get_counts() probs = counts['0010'] / sum(counts.values()) return probs
After that I want to call the function using each of the elements in my linspace.
update:Sorry maybe I was a bit unclear in my original question, if my simulation result is determined by some variable X, for each value of X, I might obtain a different probability of the state '0010'. If there're N values of X, all of which are stored in an array and I want to run my circuit N times, is there a faster way I can do that instead of manually changing the variable and record the result? Thanks for the help:)