ConceptBeginnermeasurement

Shots and Sampling

A shot is one execution of a circuit followed by measurement; repeating $N$ shots estimates probabilities and expectation values with statistical error of order $1/\sqrt N$.

Because a measurement gives a single random outcome, the same circuit is run many times, called Shots, and the outcomes are collected into Counts. The probability estimate $\hat p=k/N$ has standard error $\sqrt{p(1-p)/N}$, and the estimate of the expectation value of an observable with values $\pm1$ has error $\sqrt{(1-\langle O\rangle^2)/N}$. So to improve precision tenfold we need a hundred times as many shots.

In simulation, the probabilities are computed exactly and samples are then drawn with a random number generator. Fixing the Seed makes the results reproducible: seed= in StatevectorSampler and seed_simulator= in AerSimulator, and the lab uses a seeded generator for the same purpose. On real hardware the randomness is physical, and readout errors and noise add to it.

Shot cost is central to variational algorithms: every cost-function evaluation and every gradient component needs shots, and barren plateaus and kernel concentration mean that the differences to be detected are very small, so they need a very large number of shots.

The lab lets you change the number of shots and the seed to watch the frequencies converge to the theoretical probabilities.

Mathematical formula

$$\hat p=\frac{k}{N},\qquad \mathrm{SE}(\hat p)=\sqrt{\frac{p(1-p)}{N}}$$

Worked example

This circuit (Qiskit 2.x) measures $H|0\rangle$ with 1000 shots and seed 42:

```python
from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
qc = QuantumCircuit(1)
qc.h(0)
qc.measure_all()
result = StatevectorSampler(seed=42).run([qc], shots=1000).result()
print(result[0].data.meas.get_counts())
```

The actual output with this seed: {'1': 497, '0': 503}. The ratio $0.503$ is within the expected standard error $\sqrt{0.25/1000}\approx0.016$ of the theoretical value $0.5$. Changing the seed changes the counts.

Test your understanding

The quiz needs JavaScript.

Related topics

References

  1. IBM Quantum (2025). Qiskit SDK API documentation. IBM Quantum Documentation quantum.cloud.ibm.com
  2. Qiskit contributors (2025). Qiskit Aer documentation. GitHub Pages qiskit.github.io
  3. Michael A. Nielsen; Isaac L. Chuang (2010). Quantum Computation and Quantum Information (10th Anniversary Edition). Cambridge University Press doi:10.1017/CBO9780511976667The standard reference for quantum computing; the Crossref record gives 2012 for the Cambridge Core online edition.