# braket.default_simulator.simulation module¶

class braket.default_simulator.simulation.Simulation(qubit_count: int, shots: int)[source]

Bases: object

This class tracks the evolution of a quantum system with qubit_count qubits. The state of system the evolves by application of GateOperations using the evolve() method.

Parameters: qubit_count (int) – The number of qubits being simulated. All the qubits start in the $$\ket{\mathbf{0}}$$ computational basis state. 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.
qubit_count

The number of qubits being simulated by the simulation.

Type: int
shots

The number of samples to take from the simulation.

0 means no samples are taken, and results that require sampling to calculate cannot be returned.

Type: int
evolve(operations: List[braket.default_simulator.operation.GateOperation]) → 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.

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. float – The expected value of the observable.
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.
probabilities

The probabilities of each computational basis state.

Type: np.ndarray