Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

Sampler

class Sampler(circuits: Iterable[QuantumCircuit] | QuantumCircuit | None = None, parameters: Iterable[Iterable[Parameter]] | None = None, **kwargs)

GitHub(opens in a new tab)

Bases: qiskit.primitives.base.base_sampler.BaseSampler

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

  • circuits – Circuits to be executed.
  • parameters – Parameters of each of the quantum circuits. Defaults to [circ.parameters for circ in circuits].
  • 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.

Methods

close

Sampler.close()

Close the session and free resources

run

Sampler.run(circuits, parameter_values=None, **run_options)

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

Sampler.set_options(**fields)

Set options values for the estimator.

Parameters

**fields – The fields to update the options


Attributes

circuits

Quantum circuits to be sampled.

Returns

The quantum circuits to be sampled.

options

Return options values for the estimator.

Return type

Options

Returns

options

parameters

Parameters of quantum circuits.

Returns

List of the parameters in each quantum circuit.

Was this page helpful?
Report a bug or request content on GitHub.