pygsti.report.plothelpers

Helper Functions for generating plots

Module Contents

Functions

small_eigenvalue_err_rate(sigma, direct_gst_models)

Compute per-gate error rate.

dscompare_llr_matrices(gsplaq, dscomparator)

Computes matrix of 2*log-likelihood-ratios comparing the data of dscomparator.

genericdict_matrices(gsplaq, genericdict)

drift_neglog10pvalue_matrices(gsplaq, drifttuple)

Computes matrix of -log10(pvalues) for testing the stable-circuit ("no drift") null hypothesis in each circuit.

drift_maxtvd_matrices(gsplaq, drifttuple)

Computes matrix of max-tvds for quantifying the size of any detected drift.

rated_n_sigma(dataset, model, circuits, objfn_builder)

Computes the number of standard deviations of model violation between model and data.

pygsti.report.plothelpers.small_eigenvalue_err_rate(sigma, direct_gst_models)

Compute per-gate error rate.

The per-gate error rate, extrapolated from the smallest eigvalue of the Direct GST estimate of the given circuit sigma.

Parameters

sigmaCircuit or tuple of operation labels

The gate sequence that is used to estimate the error rate

direct_gst_modelsdictionary of Models

A dictionary with keys = circuits and values = Models.

Returns

float

the approximate per-gate error rate.

pygsti.report.plothelpers.dscompare_llr_matrices(gsplaq, dscomparator)

Computes matrix of 2*log-likelihood-ratios comparing the data of dscomparator.

Parameters

gsplaqCircuitPlaquette

Obtained via CircuitStructure.get_plaquette(), this object specifies which matrix indices should be computed and which circuits they correspond to.

dscomparatorDataComparator

The object specifying the data to be compared.

Returns

numpy array of shape ( len(effect_strs), len(prep_strs) )

log-likelihood-ratio values corresponding to the circuits where a base circuit is sandwiched between the each prep-fiducial and effect-fiducial pair.

pygsti.report.plothelpers.genericdict_matrices(gsplaq, genericdict)
pygsti.report.plothelpers.drift_neglog10pvalue_matrices(gsplaq, drifttuple)

Computes matrix of -log10(pvalues) for testing the stable-circuit (“no drift”) null hypothesis in each circuit.

This uses the “max power in spectra” test.

Parameters

gsplaqCircuitPlaquette

Obtained via CircuitStructure.get_plaquette(), this object specifies which matrix indices should be computed and which circuits they correspond to.

drifttuple2-tuple

The first element of the tuple is a StabilityAnalyzer. The second element is a tuple that specifies the hypothesis test(s) from which to extract the p-values. This can be None, and then the default is used.

Returns

numpy array of shape ( len(effect_strs), len(prep_strs) )

-log10(pvalues) for testing the “no drift” null hypothesis, using the “max power in spectra” test, on the relevant sequences. This circuits correspond to the circuits where a base circuit is sandwiched between the each prep-fiducial and effect-fiducial pair.

pygsti.report.plothelpers.drift_maxtvd_matrices(gsplaq, drifttuple)

Computes matrix of max-tvds for quantifying the size of any detected drift.

Parameters

gsplaqCircuitPlaquette

Obtained via CircuitStructure.get_plaquette(), this object specifies which matrix indices should be computed and which circuits they correspond to.

drifttuple2-tuple

The first element of the tuple is a StabilityAnalyzer. The second element is a tuple that specifies the estimatorkey, and the third element is an estimator name, that specifies the estimates to use (both can be None, and then the default is used).

Returns

numpy array of shape ( len(effect_strs), len(prep_strs) )

The max tvd for quantifying deviations from the data mean. This circuits correspond to the circuits where a base circuit is sandwiched between the each prep-fiducial and effect-fiducial pair.

pygsti.report.plothelpers.rated_n_sigma(dataset, model, circuits, objfn_builder, np=None, wildcard=None, return_all=False, comm=None)

Computes the number of standard deviations of model violation between model and data.

Function compares the data in dataset with the model model at the “points” (circuits) specified by circuits.

Parameters

datasetDataSet

The data set.

modelModel

The model (model).

circuitsCircuitList or list of Circuits

The circuits to use when computing the model violation. A CircuitList object may be given to include additional information (e.g. aliases) along with the list of circuits.

objfn_builderObjectiveFunctionBuilder

Builds the objective function to be used to compute the model violation.

npint, optional

The number of free parameters in the model. If None, then model.num_nongauge_params is used.

wildcardWildcardBudget

A wildcard budget to apply to the objective function (objective), which increases the goodness of fit by adjusting (by an amount measured in TVD) the probabilities produced by model before comparing with the frequencies in dataset. Currently, this functionality is only supported for objective == “logl”.

return_allbool, optional

Returns additional information such as the raw and expected model violation (see below).

commmpi4py.MPI.Comm, optional

When not None, an MPI communicator for distributing the computation across multiple processors.

Returns

Nsigfloat

The number of sigma of model violaition

ratingint

A 1-5 rating (e.g. “number of stars”) used to indicate the rough abililty of the model to fit the data (better fit = higher rating).

modelViolationfloat

The raw value of the objective function. Only returned when return_all==True.

expectedViolationfloat

The expected value of the objective function. Only returned when return_all==True.

Ns, npint

The number of dataset and model parameters, respectively. Only returned when return_all==True.