cirq.study.Result

The results of multiple executions of a circuit with fixed parameters.

Stored as a Pandas DataFrame that can be accessed through the "data" attribute. The repetition number is the row index and measurement keys are the columns of the DataFrame. Each element is a big endian integer representation of measurement outcomes for the measurement key in that repetition. See cirq.big_endian_int_to_bits and similar functions for how to convert this integer into bits.

params A ParamResolver of settings used for this result.
measurements A dictionary from measurement gate key to measurement results. The value for each key is a 2-D array of booleans, with the first index running over the repetitions, and the second index running over the qubits for the corresponding measurements.

params A ParamResolver of settings used when sampling result.
data

measurements

repetitions

Methods

from_single_parameter_set

View source

Packages runs of a single parameterized circuit into a Result.

Args
params A ParamResolver of settings used for this result.
measurements A dictionary from measurement gate key to measurement results. The value for each key is a 2-D array of booleans, with the first index running over the repetitions, and the second index running over the qubits for the corresponding measurements.

histogram

View source

Counts the number of times a measurement result occurred.

For example, suppose that:

- fold_func is not specified
- key='abc'
- the measurement with key 'abc' measures qubits a, b, and c.
- the circuit was sampled 3 times.
- the sampled measurement values were:
    1. a=1 b=0 c=0
    2. a=0 b=1 c=0
    3. a=1 b=0 c=0

Then the counter returned by this method will be:

collections.Counter({
    0b100: 2,
    0b010: 1
})

Where '0b100' is binary for '4' and '0b010' is binary for '2'. Notice that the bits are combined in a big-endian way by default, with the first measured qubit determining the highest-value bit.

Args
key Keys of measurements to include in the histogram.
fold_func A function used to convert a sampled measurement result into a countable value. The input is a list of bits sampled together by a measurement. If this argument is not specified, it defaults to interpreting the bits as a big endian integer.

Returns
A counter indicating how often a measurement sampled various results.

multi_measurement_histogram

View source

Counts the number of times combined measurement results occurred.

This is a more general version of the 'histogram' method. Instead of only counting how often results occurred for one specific measurement, this method tensors multiple measurement results together and counts how often the combined results occurred.

For example, suppose that:

- fold_func is not specified
- keys=['abc', 'd']
- the measurement with key 'abc' measures qubits a, b, and c.
- the measurement with key 'd' measures qubit d.
- the circuit was sampled 3 times.
- the sampled measurement values were:
    1. a=1 b=0 c=0 d=0
    2. a=0 b=1 c=0 d=1
    3. a=1 b=0 c=0 d=0

Then the counter returned by this method will be:

collections.Counter({
    (0b100, 0): 2,
    (0b010, 1): 1
})

Where '0b100' is binary for '4' and '0b010' is binary for '2'. Notice that the bits are combined in a big-endian way by default, with the first measured qubit determining the highest-value bit.

Args
fold_func A function used to convert sampled measurement results into countable values. The input is a tuple containing the list of bits measured by each measurement specified by the keys argument. If this argument is not specified, it defaults to returning tuples of integers, where each integer is the big endian interpretation of the bits a measurement sampled.
keys Keys of measurements to include in the histogram.

Returns
A counter indicating how often measurements sampled various results.

__add__

View source

__eq__

View source

Return self==value.