qiskit.opflow.state_fns.StateFn.sample¶
- StateFn.sample(shots=1024, massive=False, reverse_endianness=False)[source]¶
Sample the state function as a normalized probability distribution. Returns dict of bitstrings in order of probability, with values being probability.
- Parameters
shots (int) -- The number of samples to take to approximate the State function.
massive (bool) -- Whether to allow large conversions, e.g. creating a matrix representing over 16 qubits.
reverse_endianness (bool) -- Whether to reverse the endianness of the bitstrings in the return dict to match Terra's big-endianness.
- Returns
A dict containing pairs sampled strings from the State function and sampling frequency divided by shots.
- Return type
Dict[str, float]