0
$\begingroup$

I have been working on the ibm quantum computer platform, but i have faced a problem with the output. My circuit contains Hadamard gates and entanglement gate between two qubits. I want to get the sequence of output as [0,1,0,0,....], but they only show probabilities. How can i force the simulator to give me this sequence? Thank you in advance.

$\endgroup$
2
  • 1
    $\begingroup$ If i understand correctly, try get_memory() instead of get_counts() with the Result object. It returns an array with the lenght of the number of shots and contains the respective output of each shot as a String value e. g. ["0101","0111"]. $\endgroup$ Feb 17, 2023 at 21:02
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Feb 17, 2023 at 21:12

1 Answer 1

0
$\begingroup$

It is possible to obtain the exact measurement output of each shot by setting the memory parameter as True when executing the circuit and then using get_memory() function on the obtained result instance. For instance, to obtain the measurement output of each shot when executing a circuit circ for 10 shots, you could use

exp = execute(qc, backend, shots=10, memory=True)
out_data = exp.result().get_memory()
print(out_data)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.