Start with the question a measurement answers
A classical bit has a value of 0 or 1. A qubit also produces 0 or 1 when measured in the computational basis, but its state before that measurement needs a different description. We write it as a combination of |0> and |1> with two complex amplitudes. The squared magnitudes of those amplitudes give the probabilities of the two measurement outcomes; their sum is one.
This distinction matters when reading a simulator. A displayed probability is a prediction for repeated measurements of identically prepared states. It is not a second value stored beside a classical bit, and a single measurement does not reveal both amplitudes.
A first experiment in N/M
Open the Playground, paste this program, and run it with the local statevector simulator:
module measurement_basics;
@seed(17);
fn main() {
let q = qreg[1];
sample 256 {
H(q[0]);
let c = measure(q[0]);
}
return q;
}The register begins in |0>. The Hadamard gate, written H, prepares equal computational-basis probabilities. The ideal distribution is therefore 50% for 0 and 50% for 1. The program asks for 256 samples, so the histogram may contain unequal counts. For this ideal distribution, the standard deviation of the count for either outcome is 8; a modest difference is expected sampling variation.
The seed makes the simulator's pseudorandom sampling reproducible for a fixed program and compatible runtime. It does not describe the randomness of a physical device. The distribution is an ideal local simulation result, not a hardware calibration.
Remove H(q[0]); and run the program again. In the noiseless model the result is now always 0. This small change connects a gate instruction with an observable difference, without requiring a complicated algorithm.
Why a qubit is more than a random coin
An equal-probability superposition and a classical fifty-fifty mixture can produce the same computational-basis histogram. That histogram alone cannot distinguish them. Quantum operations can also use the relative phase of amplitudes, producing interference.
Try adding a second H(q[0]); immediately before the measurement. Two consecutive Hadamard gates cancel, so the ideal output returns to 0. The point of the experiment is the transformation of the state, not the claim that a qubit can expose every possible answer at once.
Questions to answer before moving on
- What changed when you removed the first gate?
- Why can 256 samples differ from exactly 128 zeros and 128 ones?
- What happened when you applied
Htwice? - Which information is missing from a histogram of measurements in only one basis?
If these questions feel comfortable, continue with a two-qubit Bell state. A two-qubit experiment adds correlations, while keeping the same distinction between a state, its predicted probabilities and sampled outcomes.
Sources and scope
- IBM Quantum Learning: foundational quantum-information learning materials.
- IBM: Quantum circuits: gates, circuit composition and measurement.
- N/M documentation: the language and local development workflow used in this example.
This article is an introductory explanation with a local software example. It does not report a QuantumSoftware hardware experiment or a performance advantage.