cirq.TrialResult.multi_measurement_histogram¶
-
TrialResult.multi_measurement_histogram(*, keys: Iterable[str], fold_func: Callable[Tuple[numpy.ndarray, ...], T] = <function _tuple_of_big_endian_int>) → collections.Counter[source]¶ Counts the number of times combined measurement results occurred.
This is a more general version of the ‘histogram’ method. Instead ofonly counting how often results occurred for one specific measurement,this method tensors multiple measurement results together and countshow 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’. Noticethat the bits are combined in a big-endian way by default, with thefirst measured qubit determining the highest-value bit.Parameters: - 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.