cirq.sample_density_matrix
Samples repeatedly from measurements in the computational basis.
cirq.sample_density_matrix(
density_matrix: np.ndarray,
indices: Sequence[int],
*,
qid_shape: Optional[Tuple[int, ...]] = None,
repetitions: int = 1,
seed: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None
) -> np.ndarray
Note that this does not modify the density_matrix.
Args |
density_matrix
|
The density matrix to be measured. This matrix is
assumed to be positive semidefinite and trace one. The matrix is
assumed to be of shape (2 ** integer, 2 ** integer) or
(2, 2, ..., 2).
|
indices
|
Which qubits are measured. The density matrix rows and columns
are 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 density matrix. Specify this argument
when using qudits.
|
repetitions
|
The number of times to sample the density matrix.
|
seed
|
A seed for the pseudorandom number generator.
|
Returns |
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 a numpy ndarray.
|
Raises |
ValueError
|
repetitions is less than one or size of matrix is
not a power of 2.
|
IndexError
|
An index from indices is out of range, given the number
of qubits corresponding to the density matrix.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-27 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-27 UTC."],[],[]]