deltakit.explorer.analysis.calculate_lambda_and_lambda_stddev#

deltakit.explorer.analysis.calculate_lambda_and_lambda_stddev(distances: ndarray[tuple[Any, ...], dtype[int64]] | Sequence[int], lep_per_round: ndarray[tuple[Any, ...], dtype[float64]] | Sequence[float], lep_stddev_per_round: ndarray[tuple[Any, ...], dtype[float64]] | Sequence[float], method: Literal['d', '(d+1)/2', 'direct'] = '(d+1)/2') LambdaResults#

Calculate the error suppression factor (Λ) and its standard deviation.

Requires the logical error probability (LEP) per round (which may be approximated as LEP / num_rounds for small LEP or computed with compute_logical_error_per_round() for a more precise approximation), and its standard deviation (also returned by compute_logical_error_per_round()).

By providing the logical error probability for increasing code distances, one can obtain an estimate for how error suppression scales with distances. Note that lambda is a “rule of thumb”. This approximation is unreliable near threshold and for low code distances. If such a regime is detected, a warning will be emitted by this function.

Parameters:
  • distances (npt.NDArray[numpy.int_] | Sequence[int]) – Distances at which lep_per_round and lep_stddev_per_round are provided. Should only contain odd distances. Estimations of Λ may be unreliable when data from distance 3 is used and the value of Λ is low (see Fig. S15 of Supplementary information of “Quantum error correction below the surface code threshold” at https://www.nature.com/articles/s41586-024-08449-y#Sec8). If such a situation is encountered, a warning will be emitted.

  • lep_per_round (npt.NDArray[numpy.float64] | Sequence[float]) – logical error probabilities per round computed for each code distance in distances. Should be the same size as distances.

  • lep_stddev_per_round (npt.NDArray[numpy.float64] | Sequence[float]) – standard deviation of the logical error probabilities per round computed for each code distance in distances. Should be the same size as distances.

  • method (Literal["d", "(d+1)/2", "direct"]) – mathematical method used to fit the data. Defaults to “(d+1)/2”. All 3 methods show remarkable numerical agreement, but “direct” is slower than both “d” and “(d+1)/2”, so these last 2 should be preferred in general.

Returns:

detailed results of the computation.

Return type:

LambdaResults

Note

For values of Λ very close to 1 (abs(Λ - 1) < 1e-7) and method == "direct", this function might emit a scipy.optimize._optimize.OptimizeWarning with the message "Covariance of the parameters could not be estimated".

Realistically, that condition is not expected to occur in practice due to sampling noise and sampling overhead, but it might be checked by synthetic data (e.g., in unit-tests).

Examples

Fitting the Λ value given information for 5, 7, and 9 round of a QEC experiment:

res = calculate_lambda_and_lambda_stddev(
    distances=[5, 7, 9],
    lep_per_round=[1.992e-04, 4.314e-05, 7.556e-06],
    lep_stddev_per_round=[1.2e-05, 9.3e-06, 3.9e-06],
)
lambda_, lambda_stddev = res.lambda_, res.lambda_stddev