Sampler#

class Sampler(*, backend_options: dict | None = None, transpile_options: dict | None = None, run_options: dict | None = None, skip_transpilation: bool = False)[source]#

Bases: BaseSamplerV1

Aer implementation of Sampler class.

Run Options:
  • shots (None or int) – The number of shots. If None, it calculates the probabilities exactly. Otherwise, it samples from multinomial distributions.

  • seed (int) – Set a fixed seed for seed_simulator. If shots is None, this option is ignored.

Note

Precedence of seeding is as follows:

  1. seed_simulator in runtime (i.e. in __call__())

  2. seed in runtime (i.e. in __call__())

  3. seed_simulator of backend_options.

  4. default.

Parameters:
  • backend_options – Options passed to AerSimulator.

  • transpile_options – Options passed to transpile.

  • run_options – Options passed to run.

  • skip_transpilation – if True, transpilation is skipped.

Attributes

options#

Return options values for the estimator.

Returns:

options

Methods

run(circuits: QuantumCircuit | Sequence[QuantumCircuit], parameter_values: Sequence[float] | Sequence[Sequence[float]] | None = None, **run_options) T[source]#

Run the job of the sampling of bitstrings.

Parameters:
  • circuits – One of more circuit objects.

  • parameter_values – Parameters to be bound to the circuit.

  • run_options – Backend runtime options used for circuit execution.

Returns:

The job object of the result of the sampler. The i-th result corresponds to circuits[i] evaluated with parameters bound as parameter_values[i].

Raises:

ValueError – Invalid arguments are given.

set_options(**fields)[source]#

Set options values for the estimator.

Parameters:

**fields – The fields to update the options