|q⟩ Bad Qubits

beginner · Programming · Measurement & Probability in Code

Statistics vs Single Shots

Run a quantum circuit once and you get a single, definite classical bit — either 0 or 1. Run it a thousand times and the fraction of 0 outcomes slowly converges to the probability predicted by the Born rule. These two perspectives — the single shot and the ensemble average — look very different, yet they are two sides of the same coin.

The single shot

When you measure a qubit in the state

ψ=α0+β1,|\psi\rangle = \alpha|0\rangle + \beta|1\rangle,

the outcome is irreducibly random. You get 0 with probability α2|\alpha|^2 and 1 with probability β2|\beta|^2. No matter how precisely you know the state, there is no way to predict which outcome any individual measurement will produce — this is not a limitation of the simulator or your knowledge; it is a fundamental feature of quantum mechanics.

For the equal superposition +=120+121|+\rangle = \tfrac{1}{\sqrt{2}}|0\rangle + \tfrac{1}{\sqrt{2}}|1\rangle, each shot lands on 0 or 1 with equal likelihood:

P(0)=122=12,P(1)=12.P(0) = \left|\tfrac{1}{\sqrt{2}}\right|^2 = \tfrac{1}{2}, \qquad P(1) = \tfrac{1}{2}.

The ensemble average

Repeat the same circuit NN times and count. The relative frequency of outcome 0 is

p^(0)=number of 0 outcomesN.\hat{p}(0) = \frac{\text{number of } 0 \text{ outcomes}}{N}.

By the law of large numbers, p^(0)P(0)\hat{p}(0) \to P(0) as NN \to \infty. For +|+\rangle this limit is exactly 12\tfrac{1}{2}. In the simulator a run with many shots approximates this limit; fewer shots means more scatter.

The key contrast:

| | Single shot | Ensemble average | |---|---|---| | Outcome | Definite (0 or 1) | Fractional (e.g. 0.5) | | Predictable? | No — random by nature | Yes — converges to Born-rule probability | | What it reveals | One realization | The probability distribution |

Try it

Apply the Born rule directly: return the exact probability P(0)P(0) for the state +|+\rangle. This is the value the ensemble average converges toward — not any single-shot result.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.