![]() |
A mutable container of bitstrings and associated metadata populated
cirq.work.BitstringAccumulator(
meas_spec: _MeasurementSpec,
simul_settings: List[cirq.work.InitObsSetting
],
qubit_to_index: Dict['cirq.Qid', int],
bitstrings: np.ndarray = None,
chunksizes: np.ndarray = None,
timestamps: np.ndarray = None,
readout_calibration: "BitstringAccumulator" = None
)
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.
Args | |
---|---|
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.
|
Attributes | |
---|---|
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
consume_results(
bitstrings
)
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
covariance(
*, atol=1e-08
) -> np.ndarray
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
mean(
setting: cirq.work.InitObsSetting
,
*,
atol: float = 1e-08
)
Estimates of the mean of setting
.
means
means(
*,
atol: float = 1e-08
) -> np.ndarray
Estimates of the means of the settings in this accumulator.
stderr
stderr(
setting: cirq.work.InitObsSetting
,
*,
atol: float = 1e-08
)
The standard error of the estimators for setting
.
summary_string
summary_string(
setting: cirq.work.InitObsSetting
,
number_fmt='.3f'
)
variance
variance(
setting: cirq.work.InitObsSetting
,
*,
atol: float = 1e-08
)
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__
__eq__(
other
)
Return self==value.