Skip to content
Quantum ComputingAN INTERACTIVE OPEN TEXTBOOK
charithj.com.au

Measuring and simulating quantum circuits

Know which parts of a result come from a model, a sample or a device.

12 min readDr. Charith Jayasekara↓ Chapter PDF
By the end, you’ll be able to
  • Distinguish statevector predictions, finite-shot samples and hardware evidence.
  • Record enough parameters to reproduce a small simulation.

A statevector simulation explicitly stores complex amplitudes and applies matrices. It can expose the whole ideal state because it is a classical calculation. A shot sampler draws outcomes from its squared amplitudes. Quantum hardware adds physical preparation, control, readout and environmental effects.

The first two are available here. The site does not execute hardware jobs, and adding shots to an ideal simulation does not create a hardware noise model.

Record the prepared state or circuit, gate convention, qubit order, measured basis, model, number of shots and random seed. Exact amplitudes should agree within numerical tolerance. Seeded counts should reproduce in this implementation.

L15 · INTERACTIVE LABRuns on your device

Shots & statistical uncertainty

Exact probabilities are predictions. A finite sample fluctuates. The Wilson interval describes sampling uncertainty for the probability of 1 under independent repeated preparations.

Make a prediction first

Will exactly half of 100 shots be 1? What should happen to the uncertainty interval at 10,000 shots?

Experiment controls
Exact probability
|0⟩
50.0%
|1⟩
50.0%

Exact ideal-model predictions · run a measurement experiment to compare.

MODEL · Ideal pure-state vector, complex double precisionORDER · q0 is the leftmost bit
Take it further

Keep the state fixed and change only the seed. Explain why different counts need not indicate a different quantum state.

For a fair binary measurement repeated NN times, the expected count is N/2N/2 and the count’s standard deviation is N/2\sqrt N/2. At 1,024 shots, that is 16. A difference of a few counts is unsurprising; requiring exactly 512 would be a brittle test.

The displayed Wilson interval estimates uncertainty in P(1). It does not account for correlated errors, drifting preparation or a misspecified physical model.

Generic pure-state storage grows as 2n2^n. The lab caps its input sizes and performs only small calculations so it remains responsive on a phone. Scaling a classical model is different from estimating a quantum device’s useful performance.

Challenge: give one circuit error invisible in a single Z-basis distribution. Explain which additional preparation or readout basis would reveal it.

Reference: IBM Quantum — Quantum mechanics basics.

ONE IDEA FURTHER

Ready for the next step?

Your progress stays in this browser.