sample_state_vector(state: numpy.ndarray, indices: List[int], *, qid_shape: Optional[Tuple[int, …]] = None, repetitions: int = 1, seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None) → numpy.ndarray¶
Samples repeatedly from measurements in the computational basis.
Note that this does not modify the passed in state.
state – The multi-qubit wavefunction to be sampled. This is an array of 2 to the power of the number of qubit complex numbers, and so state must be of size
2**integer. The state can be a vector of size
2**integeror a tensor of shape
(2, 2, ..., 2).
indices – Which qubits are measured. The state is assumed to be supplied in big endian order. That is the xth index of v, when expressed as a bitstring, has its largest values in the 0th index.
qid_shape – The qid shape of the state vector. Specify this argument when using qudits.
repetitions – The number of times to sample the state.
seed – A seed for the pseudorandom number generator.
Measurement results with True corresponding to the
|1⟩state. The outer list is for repetitions, and the inner corresponds to measurements ordered by the supplied qubits. These lists are wrapped as an numpy ndarray.
repetitionsis less than one or size of
stateis not a power of 2.
IndexError – An index from
indicesis out of range, given the number of qubits corresponding to the state.