pygsti.extras.paritybenchmarking.disturbancecalc.ProfileLikelihood#

class ProfileLikelihood(weight, n_bits, data_ref, data_test, solver='CLARABEL')#

Bases: object

The profile likelihood obtained by maximizing the likelihood on level-sets of constant weight-X residual-TVD.

ProfileLikelihood(residual_TVD) values are evaluated by optimizing the function:

alpha*ResidualTVD(p,q;weight) - log(Likelihood(p,q;data_ref,data_test))

for a fixed value of alpha, yielding a single (residual_TVD, ProfileLikelihood) point. The optimization is implemented as an alternating minimization between optimize-T (ResidualTVD) and optimize-(P,Q) (RegularizedLikelihood) steps.

Create a ProfileLikelihood function object.

Parameters:
  • weight (int) – The weight: all stochastic errors of this weight or below are considered “free”, i.e. contribute nothing, to the residual TVD.

  • n_bits (int) – The number of bits (qubits).

  • data_ref (numpy array) – Arrays of outcome counts from the reference and test experiments, respectively. Each array has one element per 2^n_bits bit string.

  • data_test (numpy array) – Arrays of outcome counts from the reference and test experiments, respectively. Each array has one element per 2^n_bits bit string.

  • solver (str, optional) – The name of the solver to used (see cvxpy.installed_solvers())

Methods

__init__(weight, n_bits, data_ref, data_test)

Create a ProfileLikelihood function object.

at_2llr_value(two_llr_value[, maxiters, ...])

Similar to :method:`at_delta_logl_value` except target is a 2*log-likelihood-ratio value, i.e. 2*(max_logL - logL).

at_confidence(confidence_percent[, ...])

Similar to :method:`at_logl_value` except target is a given percent confidence value, yielding a (residualTVD, ProfileLikelihood(residualTVD)) point that lies on one end of a `confidence_percent`% confidence interval of the residualTVD.

at_delta_logl_value(delta_logl_value[, ...])

Compute an (x,y) = (residualTVD, ProfileLikelihood(residualTVD)) point such that ProfileLikelihood(residualTVD) is within search_tol of logl_value.

at_logl_value(logl_value[, maxiters, ...])

__call__(log10_alpha=0, maxiters=20, reltol=1e-05, abstol=1e-05, verbosity=1, warn=True)#

Compute an (x,y) = (residualTVD, ProfileLikelihood(residualTVD)) point given a fixed value of alpha, by minimizing (w.r.t p and q):

alpha*ResidualTVD(p,q;weight) - log(Likelihood(p,q;data_ref,data_test))

Parameters:
  • log10_alpha (float) – log10(alpha), where alpha sets the strength of the regularization.

  • maxiters (int, optional) – The maximum number of alternating-minimization iterations to allow before giving up and deeming the final result “ok”.

  • reltol (float, optional) – The relative tolerance used to within the alternating minimization.

  • abstol (float, optional) – The absolute tolerance used to within the alternating minimization.

  • verbosity (int, optional) – Sets the level of detail for messages printed to the console (higher = more detail).

  • warn (bool, optional) – Whether warning messages should be issued if problems are encountered.

Returns:

  • residualTVD (float)

  • ProfileLikelihood(residualTVD) (float)

at_2llr_value(two_llr_value, maxiters=20, search_tol=0.1, reltol=1e-05, abstol=1e-05, init_log10_alpha=3, verbosity=1)#

Similar to :method:`at_delta_logl_value` except target is a 2*log-likelihood-ratio value, i.e. 2*(max_logL - logL).

at_confidence(confidence_percent, maxiters=20, search_tol=0.1, reltol=1e-05, abstol=1e-05, init_log10_alpha=3, verbosity=1)#

Similar to :method:`at_logl_value` except target is a given percent confidence value, yielding a (residualTVD, ProfileLikelihood(residualTVD)) point that lies on one end of a `confidence_percent`% confidence interval of the residualTVD.

Note that confidence_percent should be a number between 0 and 100, not 0 and 1.

at_delta_logl_value(delta_logl_value, maxiters=20, search_tol=0.1, reltol=1e-05, abstol=1e-05, init_log10_alpha=3, verbosity=1)#

Compute an (x,y) = (residualTVD, ProfileLikelihood(residualTVD)) point such that ProfileLikelihood(residualTVD) is within search_tol of logl_value.

Parameters:
  • delta_logl_value (float) – the target profile (max - log-likelihood) value.

  • maxiters (int, optional) – The maximum number of alternating-minimization iterations to allow before giving up and deeming the final result “ok”.

  • search_tol (float, optional) – The tolerance used when testing whether an obtained profile delta-log-likelihood value is close enough to delta_logl_value.

  • reltol (float, optional) – The relative tolerance used to within the alternating minimization.

  • abstol (float, optional) – The absolute tolerance used to within the alternating minimization.

  • init_log10_alpha (float, optional) – The initial log10(alpha) value to use. This shouldn’t matter except that better initial values will cause the routine to run faster.

  • verbosity (int, optional) – Sets the level of detail for messages printed to the console (higher = more detail).

Returns:

  • residualTVD (float)

  • ProfileLikelihood(residualTVD) (float)