Quantum measurement outcomes are samples from a distribution. An assertion is a statistical oracle: it decides whether the observed sample is consistent with an expected distribution or property. This page gives the math, the YAML, and guidance on choosing thresholds.
Notation: let
Passes when max_distance. The recommended default oracle:
interpretable (it's the maximum probability disagreement on any event), symmetric,
and not sensitive to shot count.
- type: distribution_tvd
expected: { "00": 0.5, "11": 0.5 }
max_distance: 0.03Typical thresholds: 0.01–0.03 on a noiseless simulator, 0.05–0.15 on noisy
hardware (the measured ibm_fez Bell TVD was 0.1284 at 4096 shots; see the
hardware baseline).
With the Bhattacharyya coefficient
Passes when min_fidelity. Identical to
qiskit.quantum_info.hellinger_fidelity. Fidelity emphasises overlap and is a common
single-number "closeness" score to track across commits.
- type: hellinger_fidelity
expected: { "00": 0.5, "11": 0.5 }
min_fidelity: 0.99With
The p-value is the chi-square survival function significance, i.e. we fail to reject the hypothesis that the
counts came from
- type: chi_square
expected: { "00": 0.5, "11": 0.5 }
significance: 0.01 # alphaNotes & caveats:
- This is the formal hypothesis test used in the quantum-testing literature as an
oracle. A smaller
significance(e.g.0.01) makes the gate more permissive (rejects only strong evidence of mismatch), reducing flakiness. - Outcomes expected with probability 0 but observed (leakage) push the statistic up and the p-value down, so the test correctly fails. (Internally, expected counts are floored at a tiny epsilon to keep the statistic finite.)
- Classical validity expects
$E_x \gtrsim 5$ per category; with many categories and few shots, preferdistribution_tvd.
Bounds the measured probability of a single basis state
# window form
- type: state_probability
state: "11"
min: 0.99
# target form
- type: state_probability
state: "00"
equals: 0.5
tolerance: 0.02Passes when all provided constraints hold: min max, and/or
tolerance. At least one of min/max/equals is
required. Ideal for amplitude-amplification checks (e.g. Grover's marked state).
Bounds the probability mass measured outside an allowed support set:
- type: allowed_states
states: ["000", "111"]
max_leakage: 0.005Passes when max_leakage. Encodes structural truths
independent of exact probabilities: a perfect GHZ state only occupies the all-zero
and all-one corners; anything else is error/leakage.
| Goal | Use |
|---|---|
| General "does the distribution match?" | distribution_tvd (default) + chi_square |
| Track closeness as one number over time | hellinger_fidelity |
| Algorithm produces a specific answer | state_probability |
| Forbid impossible outcomes / bound error | allowed_states |
A robust suite combines a distance oracle, a hypothesis test, and a structural oracle, as the Bell example does.
Sampling noise scales like seeds on
simulators to make pre-merge gates deterministic. Reserve looser thresholds for real
hardware, where device error, not sampling, dominates.