Quantum Error Correction · Stabilizer codes
Steane [[7,1,3]] code: fault-tolerance check
Enumerate every single-qubit Pauli error on the Steane code, verify its syndrome and correction, and show where distance 3 stops.
Monte Carlo logical error rate of the n-qubit bit-flip repetition code under i.i.d. bit flips, beside the exact binomial value.
Officially provided by KetQat — method by Hamming (1950), Shor (1995) and others. KetQat prepares, verifies and maintains this product; it does not claim to have invented the method. Read the origin statement.
Runs a memory experiment of the bit-flip repetition code on your machine. Each of the n data qubits flips independently with probability p; the Z_i Z_{i+1} syndrome is extracted (perfectly) and decoded by minimum weight, which for this code is majority vote; the logical qubit fails when the correction differs from the error, that is when more than n/2 qubits flipped. The product samples this with a seed and reports the logical error rate with a 95% Wilson score interval.
What makes this product useful as a reference is that the answer is known exactly: P_L = sum over k > n/2 of C(n, k) p^k (1-p)^(n-k). The exact value is reported beside the Monte Carlo estimate, together with whether it lies inside the interval, so you can see a sampling experiment and its closed form on the same output.
For students meeting error correction for the first time, and as a sanity baseline for anyone building a Monte Carlo pipeline for larger codes.
Installs the KetQat SDK from commit 2cedabbd814f, the exact version whose product definition this page shows. The SDK is not on PyPI yet, so pip install ketqat alone will not work.
pip install "ketqat[qinfo] @ git+https://github.com/ketqat/ketqat-sdk@2cedabbd814fd199b1989c8ceb1e9efa1744c2c0#subdirectory=python"Save it as example.py and run python example.py. Or use the CLI: ketqat catalog run [email protected].
import json
from ketqat_runner import catalog
record = catalog.run("[email protected]", seed=7, n=5, physical_error_rate=0.1, shots=20000)
result = record.result
interval = result["confidence_interval"]
print(json.dumps({
"status": record.status,
"n": result["n"],
"exact_logical_error_rate": round(result["exact_logical_error_rate"], 9),
"exact_within_interval": result["exact_within_interval"],
"interval_brackets_rate": interval["lower"] <= result["logical_error_rate"] <= interval["upper"],
"below_pseudothreshold": result["below_pseudothreshold"],
}))
{
"n": 5,
"status": "succeeded",
"below_pseudothreshold": true,
"exact_within_interval": true,
"interval_brackets_rate": true,
"exact_logical_error_rate": 0.00856
}Verified with
ketqat report RUN_ID sends an opt-in usage report: product, version, succeeded/failed, time and SDK version only. It shows you the exact payload first and needs an API token from Settings. Nothing is sent unless you run it.
| Name | Type | Default | Allowed values | Description |
|---|---|---|---|---|
| n | integer | 3 | maximum: 101; minimum: 1 | Number of data qubits (the code distance). Odd, so that majority vote is defined. |
| physical_error_rate | number | 0.1 | maximum: 1; minimum: 0 | Bit-flip probability p applied independently to each qubit. |
| shots | integer | 10000 | maximum: 100000000; minimum: 1 | Number of sampled experiments. n x shots above 10^9 is refused with the time estimate. |
| Name | Type | Description |
|---|---|---|
| logical_failures | integer | Shots whose decoded correction left the logical qubit flipped. |
| logical_error_rate | number | logical_failures / shots. |
| confidence_interval | object | 95% Wilson score interval: lower, upper, level, method. |
| exact_logical_error_rate | number | sum_{k > n/2} C(n, k) p^k (1-p)^(n-k), the closed form the estimate is compared with. |
| exact_within_interval | boolean | Whether the exact value lies inside the Wilson interval. |
| is_upper_bound_only | boolean | true when no failure was observed; then only the upper bound is meaningful. |
n = 3 at p = 0.1 with 10000 shots: 252 logical failures, rate 0.0252 with 95% Wilson interval [0.0223, 0.0285], which contains the exact value 3p^2 - 2p^3 = 0.028; below the pseudo-threshold, since 0.028 < 0.1.
Generated with
{"n":3,"shots":10000,"physical_error_rate":0.1}{
"n": 3,
"code": "bit-flip repetition code",
"shots": 10000,
"decoder": "majority vote (minimum-weight correction from the Z_i Z_{i+1} syndrome)",
"distance": 3,
"execution": "seeded NumPy Monte Carlo of per-qubit bit flips, syndrome extraction and majority-vote decoding",
"noise_model": "independent bit flip with probability p on each data qubit, one round, perfect syndrome measurement",
"exact_formula": "sum_{k > n/2} C(n, k) p^k (1 - p)^(n - k)",
"logical_failures": 252,
"logical_error_rate": 0.0252,
"confidence_interval": {
"level": 0.95,
"lower": 0.02230561215682308,
"upper": 0.02845903269597141,
"method": "wilson_score"
},
"is_upper_bound_only": false,
"physical_error_rate": 0.1,
"below_pseudothreshold": true,
"exact_within_interval": true,
"exact_logical_error_rate": 0.02800000000000001
}analytic agreement
For (n, p) in {(1, 0.1), (3, 0.1), (5, 0.1), (7, 0.2), (9, 0.05), (3, 0.3)} with 20000 seeded shots, the Wilson interval around the Monte Carlo rate contains the exact binomial tail, recomputed in the test with math.comb; for n = 1 the exact rate is p itself.
boundary cases
p = 0 gives zero failures, exact rate 0 and an upper-bound-only report; p = 1 flips every qubit, so every shot fails and both rates are exactly 1; p = 1/2 gives exact rate 1/2 for every odd n.
python/tests/test_catalog_products.py::test_repetition_code_boundary_cases
decoder independence
The syndrome-based decoder's failure count equals a direct majority vote on the same sampled flips, and both equal the count of shots with more than n/2 flips, on random flip tables.
python/tests/test_catalog_products.py::test_repetition_code_syndrome_decoder_equals_majority_vote
resource guard
Even n is refused, and n x shots above 10^9 is refused with the time estimate before anything runs.
python/tests/test_catalog_products.py::test_repetition_code_refuses_even_n_and_oversized_runs
example execution
The example code is executed verbatim in a clean virtual environment with only the qinfo extra installed.
1.0.01 Nov 2026currentShown on this page
Needs SDK 0.3.0 or later with extras: qinfo.
KetQat implementation of published methods
The majority-vote repetition code is classical coding theory going back to Hamming (1950); its quantum bit-flip form is the textbook three-qubit code treated by Nielsen and Chuang, and Shor (1995) used it as a building block of the first quantum error-correcting code. The Wilson score interval is due to Wilson (1927). KetQat wrote this NumPy Monte Carlo implementation (repetition_code.py), its syndrome decoder, the exact reference, the validation tests and this catalog entry. KetQat did not invent the code.
Apache-2.0 — see Licensing.
People credited for this product. KetQat publishes and maintains it; contributors are credited for their work and are not sellers.
No usage reports yet
Distinct signed-in accounts that chose to send at least one usage report (ketqat report) for this product in the last 90 days. KetQat staff, test and bot accounts are excluded. Reports are opt-in, so this is not a count of all users.
Computed 10 Nov 2026, 17:34 UTC.
Not yet rated
Be the first to rate this product after you run it.
Mean of visible reviews. Hidden reviews and reviews by KetQat staff, test and bot accounts are excluded. Pro status gives no extra weight.
Sign in to review this product. One review per person; you can edit it later.
No reviews yet.