cirq.TrialResult.histogram¶
-
TrialResult.histogram(*, key: str, fold_func: Callable[numpy.ndarray, T] = <function _big_endian_int>) → collections.Counter[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’. Noticethat the bits are combined in a big-endian way by default, with thefirst measured qubit determining the highest-value bit.Parameters: - positional_args – Never specified. Forces keyword arguments.
- 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.