cirq.work.BitstringAccumulator

A mutable container of bitstrings and associated metadata populated

during a measure_observables run.

This object contains all raw results and can be serialized via JSON to keep a record of your experiment results. There are also various utility methods that can be used to chain a series of BitstringAccumulator results into a form more suitable for analysis like a pandas DataFrame.

By default, this will be initialized empty. This should only be mutated by calling consume_results. Do not mutate values directly.

meas_spec The specification with the particular run used to gather these bitstrings. There should be a 1-to-1 correspondence between bitstring accumulators and circuits run on a quantum sampler.
simul_settings The list of settings consistent with this measurement spec, usually the result of grouping a list of requested settings. This list need not be exhausted: any setting consistent with the meas_spec can be queried with methods that take a setting as argument (e.g. mean, variance) whether or not they are provided up-front in simul_settings. Those methods that do not take a setting as an argument (e.g. means, variances) will report all values for the settings in simul_settings.
qubit_to_index A mapping from qubits to contiguous indices starting from zero. This allows us to store bitstrings as a 2d numpy array.
chunksizes This class accumulates bitstrings from potentially several "chunked" processor runs. Each chunk has a certain number of repetitions, recorded in this array. This theoretically allows you to re-split up the bitstring array should the need arise. The total number of repetitions is the sum of this 1d array.
timestamps We record a timestamp for each request/chunk. This 1d array will have the same length as chunksizes.
readout_calibration The result of calibrate_readout_error. When requesting means and variances, if this is not None, we will use the calibrated value to correct the requested quantity. This is a BitstringAccumulator containing the results of measuring Z observables with readout symmetrization enabled. This class does not validate that both this parameter and the BitstringAccumulator under construction contain measurements taken with readout symmetrization turned on.

circuit_params

max_setting

meas_spec

n_repetitions

qubit_to_index

records Yield individual setting results as dictionary records.

This is suitable for passing to pd.DataFrame constructor, perhaps after chaining these results with those from other BitstringAccumulators.

results Yield individual setting results as ObservableMeasuredResult objects.
simul_settings

Methods

consume_results

View source

Add bitstrings sampled according to meas_spec.

We don't validate that bitstrings were sampled correctly according to meas_spec (how could we?) so please be careful. Consider using measure_observables rather than calling this method yourself.

covariance

View source

Compute the covariance matrix for the estimators of all settings.

Like variance, this is the covariance of the sampling distribution of the sample mean. Practically, it is the 'normal' covariance divided by the number of observations (bitstrings).

Args
atol The absolute tolerance for asserting coefficients are real.

mean

View source

Estimates of the mean of setting.

means

View source

Estimates of the means of the settings in this accumulator.

stderr

View source

The standard error of the estimators for setting.

summary_string

View source

variance

View source

Compute the variance of the estimators of the given setting.

This is the normal variance divided by the number of samples to estimate the certainty of our estimate of the mean. It is the standard error of the mean, squared.

This uses ddof=1 during the call to np.var for an unbiased estimator of the variance in a hypothetical infinite population for consistency with BitstringAccumulator.covariance() but differs from the default for np.var.

Args
setting The setting
atol The absolute tolerance for asserting coefficients are real.

__eq__

View source

Return self==value.