Skip to main contentIBM Quantum Documentation Mirror

Sampler

class qiskit.primitives.Sampler(*, options=None)

GitHub(opens in a new tab)

Bases: BaseSampler[PrimitiveJob[SamplerResult]]

Sampler V1 class.

Sampler is a reference implementation of BaseSampler (V1).

Run Options

  • shots (None or int) – The number of shots. If None, it calculates the probabilities. Otherwise, it samples from multinomial distributions.
  • seed (np.random.Generator or int) – Set a fixed seed or generator for the multinomial distribution. If shots is None, this option is ignored.
Deprecated since version 1.2

The class qiskit.primitives.sampler.Sampler is deprecated as of qiskit 1.2. It will be removed no earlier than 3 months after the release date. All implementations of the BaseSamplerV1 interface have been deprecated in favor of their V2 counterparts. The V2 alternative for the Sampler class is StatevectorSampler.

Parameters

options (dict(opens in a new tab) | None) – Default options.

Raises

QiskitError – if some classical bits are not used for measurements.


Attributes

options

Return options values for the estimator.

Returns

options


Methods

run

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

GitHub(opens in a new tab)

Run the job of the sampling of bitstrings.

Parameters

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(opens in a new tab) – Invalid arguments are given.

Return type

T

set_options

set_options(**fields)

GitHub(opens in a new tab)

Set options values for the estimator.

Parameters

**fields – The fields to update the options