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 GateOperation`s 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.

property qubit_count: int

The number of qubits being simulated by the simulation.

Type:

int

property shots: int

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[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: 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.

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.

property probabilities: ndarray

The probabilities of each computational basis state.

Type:

np.ndarray