braket.default_simulator.density_matrix_simulation module¶

class
braket.default_simulator.density_matrix_simulation.
DensityMatrixSimulation
(qubit_count: int, shots: int)[source]¶ Bases:
braket.default_simulator.simulation.Simulation
This class tracks the evolution of the density matrix of a quantum system with
qubit_count
qubits. The state of system evolves by applications ofGateOperation`s and `KrausOperation`s using the `evolve()
method.Parameters:  qubit_count (int) – The number of qubits being simulated.
 shots (int) – The number of samples to take from the simulation. If set to 0, only results that do not require sampling, such as density matrix or expectation, are generated.

evolve
(operations: List[Union[braket.default_simulator.operation.GateOperation, braket.default_simulator.operation.KrausOperation]]) → None[source]¶ Evolves the state of the simulation under the action of the specified gate operations.
Parameters: operations (List[GateOperation]) – Gate operations to apply for evolving the state of the simulation. Note
This method mutates the state of the simulation.

apply_observables
(observables: List[braket.default_simulator.operation.Observable]) → None[source]¶ Applies the diagonalizing matrices of the given observables to the state of the simulation.
This method can only be called once.
Parameters: observables (List[Observable]) – The observables to apply Raises: RuntimeError
– If this method is called more than once

retrieve_samples
() → List[int][source]¶ Retrieves samples of states from the state of the simulation, based on the probabilities.
Returns: List[int] – List of states sampled according to their probabilities in the state. Each integer represents the decimal encoding of the corresponding computational basis state.

density_matrix
¶ The density matrix specifying the current state of the simulation.
Note
Mutating this array will mutate the state of the simulation.
Type: np.ndarray

state_with_observables
¶ The density matrix diagonalized in the basis of the measured observables.
Raises: RuntimeError
– If observables have not been appliedType: np.ndarray

expectation
(observable: braket.default_simulator.operation.Observable) → float[source]¶ The expected value of the observable in the given state.
Parameters: observable (Observable) – The observable to measure. Returns: float – The expected value of the observable.

probabilities
¶ The probabilities of each computational basis state of the current density matrix of the simulation.
Type: np.ndarray