Quantum Computing 101
Measurement
Measurement is where a quantum state becomes classical data, and it changes the state it reads.
In this lesson you will learn to
- Predict measurement probabilities and the counts you expect over many shots.
- Explain collapse and why repeated measurements agree.
- Measure in the X or Y basis by rotating the state first.
- Sample measurement counts from a state in Qiskit.
Shots and Counts
Measuring a qubit gives one classical bit. You never see α or β directly, only a 0 or a 1.
To learn the probabilities you repeat the experiment. Each repetition is called a shot. Over many shots, the fraction of 0s approaches |α|² and the fraction of 1s approaches |β|².
Worked example: probabilities and shots
Use a state with a larger amplitude for |0⟩ than for |1⟩.
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
import math
qc = QuantumCircuit(1)
qc.ry(math.pi / 3, 0) # amplitudes sqrt(3)/2 and 1/2
state = Statevector.from_instruction(qc)
print(state.sample_counts(shots=1000))
# e.g. {'0': 742, '1': 258} (different every run)Collapse
Measurement does not just read the qubit; it changes it. After you observe 0 the state is |0⟩, and after you observe 1 it is |1⟩. This is called collapse.
If no gate acts in between, measuring again gives the same answer with certainty. The randomness happens once, at the first measurement.
Worked example: measure twice
›Check yourself: A qubit in |+⟩ is measured and gives 1. You then apply H and measure again. What are the odds now?
After the first measurement the state is |1⟩. H turns it into |−⟩, so the second measurement is 50/50. Without the first measurement, H would have turned |+⟩ into |0⟩ and you would read 0 every time: the early measurement destroyed the interference.
Measuring in Other Bases
Hardware measures in the Z basis: it asks "0 or 1?". To ask a different question, rotate the state first. Applying H before measuring turns |+⟩ into 0 and |−⟩ into 1, so H followed by a measurement is an X-basis measurement.
For the Y basis, apply S† and then H before measuring. The same trick lets you estimate how much of a state points along any axis.
Worked example: reading |−⟩ in the X basis
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
qc = QuantumCircuit(1)
qc.x(0)
qc.h(0) # prepare |->
qc.h(0) # rotate the X basis onto the Z basis
print(Statevector.from_instruction(qc).probabilities_dict(decimals=3))
# {'1': 1.0}: |-> reads as 1Key Takeaways
- A single shot returns one bit; probabilities only show up in counts over many shots.
- Counts approach |α|² and |β|², with noise shrinking like 1/√shots.
- Measurement collapses the state onto the result, so repeating it gives the same answer.
- Rotate before measuring to measure in another basis: H for X, S† then H for Y.
What To Practice
Practice predicting outcomes, choosing the right measurement basis, and decoding two-qubit states.
- Mixed-Basis ReadoutEasy ★Rotate each qubit so a mix of X, Y and Z measurements reads out correctly.
- Loaded Twin CoinsEasy ★Design a state whose outcomes have exactly the odds you choose.
- Bell Basis DecoderEasy ★Turn Bell-basis information into two classical bits using a custom lookup table.
- Quantum TeleportationMedium ★★Use measurement results, deferred into controlled gates, to finish a protocol.