# Simple Hadamard Circuit gives incorrect results?

I am running the simplest Hadamard circuit possible - one qubit, initialised to 0, apply H gate, measure in Z basis. When I run the circuit on the simulator I obtain the expected result (50% in 0, 50% in 1) but the "measurement probability" and "state vector" from the IBM Circuit Composer indicate I am in the state $$|0\rangle$$, with 100% probability to measure 0. Am I understanding this visualisation wrong? Why don't I see the 50%/50% measurement probabilities and the state vector to be $$(\frac{1}{\sqrt{2}})(|0\rangle + |1\rangle)$$?

Just to a little bit expand answer provided by Zhaoyi Zhou.

First, try to put only reset gate and Hadamard gate on the qubit. In this case, you will see probability of measuring 0 and 1 equal to 50 % and state vector will be $$\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$. Note that you do not have to use reset gate as the qubit is initially in state $$|0\rangle$$.

Now, add the measurement gate. When you do so, the state collapses to 0 or 1 which is indicated by 100 % probability in the histogram.

Overall, the visualization shows state vector of the circuit only in case, there is no measurement gates.

IBM Quantum Composer shows the measurement probability after the gate have been applied.

Hence, if you apply the Hadamard gate to the state $$|0\rangle$$

then you will see the probability as:

But now, if you add the measurement to the circuit, then Qiskit will collapse your state to either $$|0\rangle$$ or $$|1\rangle$$. Then the post measurement state will be either $$|0\rangle$$ or $$|1\rangle$$ with 100% probability. However, this doesn't seems to happen within the circuit composer. That is the state will always collapse to the state $$|0\rangle$$ by default. That is, the following circuit will always seem to collapse to the state $$|0\rangle$$ by default.

And if you reset the qubit after the measurement to the state $$|0\rangle$$ again then apply the Hadamard gate then measure, it will always collapse to the state $$|1\rangle$$ by default, interestingly.

For this reason, my proposal solution would just to run your circuit in Qiskit through the Jupyter notebook setting in QuantumLab environment and use the qasm_simulator. This will fix this issue. So you can compose your circuit in the Quantum Composer as normal, then just get the generated Qiskit code:

then you can run this Qiskit code in the Jupyter notebook within the QuantumLab for better visualization. You can do this simply by adding the code below additional to the code you got earlier.

from qiskit import BasicAer, execute
from qiskit.visualization import plot_histogram
%matplotlib inline
backend = BasicAer.get_backend('qasm_simulator')
job = execute(circuit, backend, shots = 1000)
plot_histogram(job.result().get_counts(), color='black', title="Result")


You could actually execute your circuit through the quantum composer and selectibmq_qasm_simulator as your backend but I think it is faster and more flexible if you just migrate your circuit to Qiskit code and execute it through the Jupyter notebook in quantum lab.

• Thanks for the response... Interesting (strange?) that there are "default" measurement results...still seems counterintuitive to me (especially since, as you said, the default result changes - deterministically - between 0 and 1!) I'd be curious to here why this was programmed this way. In any case, thanks for the tip about just switching the backend on jupyter. Jan 1, 2021 at 19:27
• You can seed the randomness of the measurement by changing the value in the Simulator seed box, on the top bar. If you change this value, you will notice that you will have half of the times a 0, and half of the time a 1. The reason for that is because the simulator makes a single shot, so a you obtain a single result at the time. Jan 1, 2021 at 20:21
• Ah ok, that makes sense, thanks! Jan 4, 2021 at 12:17
• In the IBMQ Composer, selecting the system ibmq_qasm_simlator seems to have the same funny behavior.
– ZxJx
Feb 24, 2021 at 15:46