pygsti.drivers.bootstrap

Functions for generating bootstrapped error bars

Module Contents

Functions

create_bootstrap_dataset(input_data_set, generation_method, input_model=None, seed=None, outcome_labels=None, verbosity=1)

Creates a DataSet used for generating bootstrapped error bars.

create_bootstrap_models(num_models, input_data_set, generation_method, fiducial_prep, fiducial_measure, germs, max_lengths, input_model=None, target_model=None, start_seed=0, outcome_labels=None, lsgst_lists=None, return_data=False, verbosity=2)

Creates a series of "bootstrapped" Models.

gauge_optimize_models(gs_list, target_model, gate_metric='frobenius', spam_metric='frobenius', plot=True)

Optimizes the "spam weight" parameter used when gauge optimizing a set of models.

_model_stdev(gs_func, gs_ensemble, ddof=1, axis=None, **kwargs)

Standard deviation of gs_func over an ensemble of models.

_model_mean(gs_func, gs_ensemble, axis=None, **kwargs)

Mean of gs_func over an ensemble of models.

_to_mean_model(gs_list, target_gs)

Take the per-gate-element mean of a set of models.

_to_std_model(gs_list, target_gs, ddof=1)

Take the per-gate-element standard deviation of a list of models.

_to_rms_model(gs_list, target_gs)

Take the per-gate-element RMS of a set of models.

pygsti.drivers.bootstrap.create_bootstrap_dataset(input_data_set, generation_method, input_model=None, seed=None, outcome_labels=None, verbosity=1)

Creates a DataSet used for generating bootstrapped error bars.

Parameters
  • input_data_set (DataSet) – The data set to use for generating the “bootstrapped” data set.

  • generation_method ({ 'nonparametric', 'parametric' }) – The type of dataset to generate. ‘parametric’ generates a DataSet with the same circuits and sample counts as input_data_set but using the probabilities in input_model (which must be provided). ‘nonparametric’ generates a DataSet with the same circuits and sample counts as input_data_set using the count frequencies of input_data_set as probabilities.

  • input_model (Model, optional) – The model used to compute the probabilities for circuits when generation_method is set to ‘parametric’. If ‘nonparametric’ is selected, this argument must be set to None (the default).

  • seed (int, optional) – A seed value for numpy’s random number generator.

  • outcome_labels (list, optional) – The list of outcome labels to include in the output dataset. If None are specified, defaults to the spam labels of input_data_set.

  • verbosity (int, optional) – How verbose the function output is. If 0, then printing is suppressed. If 1 (or greater), then printing is not suppressed.

Returns

DataSet

pygsti.drivers.bootstrap.create_bootstrap_models(num_models, input_data_set, generation_method, fiducial_prep, fiducial_measure, germs, max_lengths, input_model=None, target_model=None, start_seed=0, outcome_labels=None, lsgst_lists=None, return_data=False, verbosity=2)

Creates a series of “bootstrapped” Models.

Models are created from a single DataSet (and possibly Model) and are typically used for generating bootstrapped error bars. The resulting Models are obtained by performing MLGST on data generated by repeatedly calling :function:`create_bootstrap_dataset` with consecutive integer seed values.

Parameters
  • num_models (int) – The number of models to create.

  • input_data_set (DataSet) – The data set to use for generating the “bootstrapped” data set.

  • generation_method ({ 'nonparametric', 'parametric' }) – The type of data to generate. ‘parametric’ generates DataSets with the same circuits and sample counts as input_data_set but using the probabilities in input_model (which must be provided). ‘nonparametric’ generates DataSets with the same circuits and sample counts as input_data_set using the count frequencies of input_data_set as probabilities.

  • fiducial_prep (list of Circuits) – The state preparation fiducial circuits used by MLGST.

  • fiducial_measure (list of Circuits) – The measurement fiducial circuits used by MLGST.

  • germs (list of Circuits) – The germ circuits used by MLGST.

  • max_lengths (list of ints) – List of integers, one per MLGST iteration, which set truncation lengths for repeated germ strings. The list of circuits for the i-th LSGST iteration includes the repeated germs truncated to the L-values up to and including the i-th one.

  • input_model (Model, optional) – The model used to compute the probabilities for circuits when generation_method is set to ‘parametric’. If ‘nonparametric’ is selected, this argument must be set to None (the default).

  • target_model (Model, optional) – Mandatory model to use for as the target model for MLGST when generation_method is set to ‘nonparametric’. When ‘parametric’ is selected, input_model is used as the target.

  • start_seed (int, optional) – The initial seed value for numpy’s random number generator when generating data sets. For each succesive dataset (and model) that are generated, the seed is incremented by one.

  • outcome_labels (list, optional) – The list of Outcome labels to include in the output dataset. If None are specified, defaults to the effect labels of input_data_set.

  • lsgst_lists (list of circuit lists, optional) – Provides explicit list of circuit lists to be used in analysis; to be given if the dataset uses “incomplete” or “reduced” sets of circuit. Default is None.

  • return_data (bool) – Whether generated data sets should be returned in addition to models.

  • verbosity (int) – Level of detail printed to stdout.

Returns

  • models (list) – The list of generated Model objects.

  • data (list) – The list of generated DataSet objects, only returned when return_data == True.

pygsti.drivers.bootstrap.gauge_optimize_models(gs_list, target_model, gate_metric='frobenius', spam_metric='frobenius', plot=True)

Optimizes the “spam weight” parameter used when gauge optimizing a set of models.

This function gauge optimizes multiple times using a range of spam weights and takes the one the minimizes the average spam error multiplied by the average gate error (with respect to a target model).

Parameters
  • gs_list (list) – The list of Model objects to gauge optimize (simultaneously).

  • target_model (Model) – The model to compare the gauge-optimized gates with, and also to gauge-optimize them to.

  • gate_metric ({ "frobenius", "fidelity", "tracedist" }, optional) – The metric used within the gauge optimization to determing error in the gates.

  • spam_metric ({ "frobenius", "fidelity", "tracedist" }, optional) – The metric used within the gauge optimization to determing error in the state preparation and measurement.

  • plot (bool, optional) – Whether to create a plot of the model-target discrepancy as a function of spam weight (figure displayed interactively).

Returns

list – The list of Models gauge-optimized using the best spamWeight.

pygsti.drivers.bootstrap._model_stdev(gs_func, gs_ensemble, ddof=1, axis=None, **kwargs)

Standard deviation of gs_func over an ensemble of models.

Parameters
  • gs_func (function) – A function that takes a Model as its first argument, and whose additional arguments may be given by keyword arguments.

  • gs_ensemble (list) – A list of Model objects.

  • ddof (int, optional) – As in numpy.std

  • axis (int or None, optional) – As in numpy.std

Returns

numpy.ndarray – The output of numpy.std

pygsti.drivers.bootstrap._model_mean(gs_func, gs_ensemble, axis=None, **kwargs)

Mean of gs_func over an ensemble of models.

Parameters
  • gs_func (function) – A function that takes a Model as its first argument, and whose additional arguments may be given by keyword arguments.

  • gs_ensemble (list) – A list of Model objects.

  • axis (int or None, optional) – As in numpy.mean

Returns

numpy.ndarray – The output of numpy.mean

pygsti.drivers.bootstrap._to_mean_model(gs_list, target_gs)

Take the per-gate-element mean of a set of models.

Return the Model constructed from the mean parameter vector of the models in gs_list, that is, the mean of the parameter vectors of each model in gs_list.

Parameters
  • gs_list (list) – A list of Model objects.

  • target_gs (Model) – A template model used to specify the parameterization of the returned Model.

Returns

Model

pygsti.drivers.bootstrap._to_std_model(gs_list, target_gs, ddof=1)

Take the per-gate-element standard deviation of a list of models.

Return the Model constructed from the standard-deviation parameter vector of the models in gs_list, that is, the standard- devaiation of the parameter vectors of each model in gs_list.

Parameters
  • gs_list (list) – A list of Model objects.

  • target_gs (Model) – A template model used to specify the parameterization of the returned Model.

  • ddof (int, optional) – As in numpy.std

Returns

Model

pygsti.drivers.bootstrap._to_rms_model(gs_list, target_gs)

Take the per-gate-element RMS of a set of models.

Return the Model constructed from the root-mean-squared parameter vector of the models in gs_list, that is, the RMS of the parameter vectors of each model in gs_list.

Parameters
  • gs_list (list) – A list of Model objects.

  • target_gs (Model) – A template model used to specify the parameterization of the returned Model.

Returns

Model