Sampling Error
Every quantum experiment involves finite statistics: you run a circuit times (called shots or runs), count how many times a particular outcome appears, and report that count divided by as your estimated probability. Understanding how much to trust that estimate is the subject of sampling error.
The estimated probability and why it fluctuates
Suppose the true, underlying probability of outcome "1" is (unknown). Each shot is an independent Bernoulli trial that returns 1 with probability and 0 with probability .
If you observe ones in shots, the natural estimate is
Because is a random variable, is also random — it will differ slightly each time you repeat the -shot experiment. The count follows a binomial distribution with parameters and :
Dividing by to form simply scales both the mean and the variance:
The first line says is an unbiased estimator of : on average it gets the right answer. The second line says the spread around shrinks as grows — exactly the law of large numbers in action.
Standard error: the key formula
The standard error (SE) of is the standard deviation of the sampling distribution:
In practice itself is unknown, so we substitute the estimate :
This is the number you quote when someone asks "how precisely do you know your probability?"
How the formula behaves
Two features are worth internalising:
Scaling with shots. The SE shrinks as . Halving the error requires four times as many shots; cutting it by ten requires one hundred times as many. This square-root growth is a fundamental statistical fact and places a practical limit on how quickly you can pin down a quantum probability.
Maximum at . The numerator is a downward-opening parabola maximised at , where it equals . At that point
So a balanced coin-flip outcome is the hardest to pin down; extreme probabilities near 0 or 1 have smaller sampling error because nearly every shot gives the same result.
A worked example
You run a quantum circuit times and record "one" outcomes. The estimated probability is . The estimated standard error is
= \sqrt{0.0024} \approx 0.049.$$ You would report $p \approx 0.40 \pm 0.05$ — a roughly 5 % uncertainty. To reduce that to 1 % you would need approximately $0.24 / (0.01)^2 = 2400$ shots. ## Why this matters in quantum computing Quantum computers are inherently probabilistic: most algorithms — Shor's, Grover's, variational algorithms — produce outputs that must be **sampled** from a probability distribution. The precision of any experimentally measured quantity (an expectation value, a probability, an energy estimate) is limited by the number of circuit evaluations. Understanding sampling error lets you budget your shot count before running expensive experiments on real hardware. <Callout type="tip"> A quick sanity check: the standard error must lie in the range $[0, 0.5/\sqrt{n}]$. If your calculation produces a number outside this range, check whether you divided by $n$ inside the square root, not outside it. </Callout> ## Try it This is a numerical exercise — your code should `return` a number, not a circuit. You observe $k = 40$ successes in $n = 100$ shots. Return the standard error $\widehat{\sigma}_{\hat{p}} = \sqrt{\hat{p}(1-\hat{p})/n}$. <RunnableExample />Sign in on the full site to ask questions and join the discussion.