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.
-
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$– Enrique Anguiano VaraFeb 17 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 BotFeb 17 at 21:12
1 Answer
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)