Skip to main content
KetQat

Appearance

Repetition code memory (bit-flip)

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.

What it does and who it is for

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.

Use cases

  • Watch the logical error rate fall with n below the pseudo-threshold p = 1/2 and rise above it
  • Check a Monte Carlo pipeline (sampling, decoding, confidence intervals) against an exact closed form
  • Produce a seeded, reproducible memory-experiment record with a Wilson interval for a chosen (n, p, shots)

Use it on your computer

This page never runs anything. Copy the commands into your own terminal; the product runs locally with no account and no telemetry.
  1. Install

    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.

    Terminal
    pip install "ketqat[qinfo] @ git+https://github.com/ketqat/ketqat-sdk@2cedabbd814fd199b1989c8ceb1e9efa1744c2c0#subdirectory=python"
  2. Run the example

    Save it as example.py and run python example.py. Or use the CLI: ketqat catalog run [email protected].

    Python
    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"],
    }))
    
    Expected output (fields the example must print)
    {
      "n": 5,
      "status": "succeeded",
      "below_pseudothreshold": true,
      "exact_within_interval": true,
      "interval_brackets_rate": true,
      "exact_logical_error_rate": 0.00856
    }

    Verified with

    SDK
    0.3.0
    Python
    3.12.12
    Platform
    macOS-27.0.1-arm64 Python 3.12.12 (maintainer run in a clean virtualenv, test_catalog_examples.py)
    Date
    1 Nov 2026
  3. Optional: tell us it ran

    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.

Inputs and outputs

Inputs

Inputs of Repetition code memory (bit-flip)
NameTypeDefaultAllowed valuesDescription
ninteger3maximum: 101; minimum: 1Number of data qubits (the code distance). Odd, so that majority vote is defined.
physical_error_ratenumber0.1maximum: 1; minimum: 0Bit-flip probability p applied independently to each qubit.
shotsinteger10000maximum: 100000000; minimum: 1Number of sampled experiments. n x shots above 10^9 is refused with the time estimate.

Outputs

Outputs of Repetition code memory (bit-flip)
NameTypeDescription
logical_failuresintegerShots whose decoded correction left the logical qubit flipped.
logical_error_ratenumberlogical_failures / shots.
confidence_intervalobject95% Wilson score interval: lower, upper, level, method.
exact_logical_error_ratenumbersum_{k > n/2} C(n, k) p^k (1-p)^(n-k), the closed form the estimate is compared with.
exact_within_intervalbooleanWhether the exact value lies inside the Wilson interval.
is_upper_bound_onlybooleantrue when no failure was observed; then only the upper bound is meaningful.

Sample result

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

Product version
1.0.0
Seed
7
Parameters
{"n":3,"shots":10000,"physical_error_rate":0.1}
SDK
0.3.0
Python
3.12.12
Platform
macOS-27.0.1-arm64-arm-64bit
Result data (JSON)
{
  "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
}

Assumptions, scope and limitations

Assumptions

  • Independent, identically distributed bit flips (X errors) with probability p on each data qubit, applied once.
  • Perfect syndrome measurement and a single round: no measurement errors, no idling errors and no repeated extraction.
  • Minimum-weight decoding from the Z_i Z_{i+1} syndrome, which equals majority vote for this code; the decoder is cross-checked against a direct majority vote on every chunk.

Scope

  • Odd n from 1 to 101 and any p in [0, 1]; up to 10^9 sampled qubit flips per run.
  • Logical error rate per experiment with a 95% Wilson score interval and the exact binomial value.

Limitations

  • A bit-flip code protects against X errors only; phase flips are not modelled and the code would not correct them.
  • No circuit-level noise, no measurement errors and no multi-round memory: the rate is per single round with perfect syndromes, which is why it has a closed form.
  • Zero observed failures is reported as an upper bound, not as a rate of zero; at small p and small shot counts the interval is wide.
  • Sampled counts are reproducible for the same seed with the same NumPy version; NumPy does not guarantee identical random streams across versions.
  • Tested on macOS and Linux only; Windows is untested.

Environment and resources

Runs
Locally, on your computer
Type
Simulation
Python
>=3.10
Operating systems
Linux, macOS
Resources
n=3 with 10^4 shots: milliseconds. 10^8 sampled qubit flips (for example n=11 with 10^7 shots): ~1.5 s and under 100 MB on a 2024 laptop; shots are processed in fixed chunks so memory stays bounded. n x shots above 10^9 (~15 s) is refused.
SDK extras
qinfo
Minimum SDK
0.3.0

Validation

Verified: the example was executed by CI, validation tests exist and limitations are recorded.

Versions and changelog

  1. 1.0.01 Nov 2026currentShown on this page

    • First catalog release: NumPy Monte Carlo of the bit-flip repetition code with syndrome decoding, Wilson interval and exact binomial reference.

    Needs SDK 0.3.0 or later with extras: qinfo.

All product changelogs

Origin, license and credits

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.

Upstream software

License of what you receive

Apache-2.0 — see Licensing.

Contributors

People credited for this product. KetQat publishes and maintains it; contributors are credited for their work and are not sellers.

  • dorakingx · KetQat maintainer: implementation, validation and catalog entry

How to contribute

References

  1. R. W. Hamming (1950). Error detecting and error correcting codes. The Bell System Technical Journal 29, 147-160.
  2. Peter W. Shor (1995). Scheme for reducing decoherence in quantum computer memory. Physical Review A 52, R2493-R2496.DOI 10.1103/PhysRevA.52.R2493
  3. Michael A. Nielsen, Isaac L. Chuang (2010). Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge University Press.DOI 10.1017/CBO9780511976667
  4. Edwin B. Wilson (1927). Binomial confidence intervals: Probable inference, the law of succession, and statistical inference. Journal of the American Statistical Association 22, 209-212.

Usage

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.

Reviews

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.