Skip to main content
IBM Quantum Platform

BaseSamplerV1

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

GitHub

ベース: BasePrimitiveV1, Generic[T]

サンプラー V1 基本クラス

量子回路からビット列の準確率を計算するサンプラーの基本クラス。

サンプラーは空のパラメーターセットで初期化される。 サンプラーは JobV1を、 qiskit.primitives.Sampler.run() メソッドで実行する。 このメソッドは以下のパラメータで呼び出される

  • quantum circuits ( ψi(θ)\psi_i(\theta) ): (パラメータ化された)量子回路のリスト。 (オブジェクトのリスト QuantumCircuit オブジェクトのリスト)
  • parameter values ( θk\theta_k ): 量子回路のパラメータに束縛されるパラメータ値のセットのリスト。 (フロートのリストのリスト)

このメソッドは JobV1 オブジェクトを返します。 qiskit.providers.JobV1.result() を呼び出すと SamplerResult このオブジェクトには、ビット列の確率または準確率と、サンプルのエラーバーのようなオプションのメタデータが含まれます。

以下はサンプラーの使用例である。

# This is a fictional import path.
# There are currently no Sampler implementations in Qiskit.
from sampler_v1_location import SamplerV1
from qiskit import QuantumCircuit
from qiskit.circuit.library import RealAmplitudes

# a Bell circuit
bell = QuantumCircuit(2)
bell.h(0)
bell.cx(0, 1)
bell.measure_all()

# two parameterized circuits
pqc = RealAmplitudes(num_qubits=2, reps=2)
pqc.measure_all()
pqc2 = RealAmplitudes(num_qubits=2, reps=3)
pqc2.measure_all()

theta1 = [0, 1, 1, 2, 3, 5]
theta2 = [0, 1, 2, 3, 4, 5, 6, 7]

# initialization of the sampler
sampler = Sampler()

# Sampler runs a job on the Bell circuit
job = sampler.run(circuits=[bell], parameter_values=[[]], parameters=[[]])
job_result = job.result()
print([q.binary_probabilities() for q in job_result.quasi_dists])

# Sampler runs a job on the parameterized circuits
job2 = sampler.run(
    circuits=[pqc, pqc2],
    parameter_values=[theta1, theta2],
    parameters=[pqc.parameters, pqc2.parameters])
job_result = job2.result()
print([q.binary_probabilities() for q in job_result.quasi_dists])

SamplerV1 を初期化する。

パラメーター

options (dict | None) – デフォルトのオプション。


属性

options

推定値のオプション値を返す。

戻り値

オプション


方法

run

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

GitHub

ビット列のサンプリングのジョブを実行する。

パラメーター

戻り値

サンプラー結果のジョブオブジェクト。 i 番目の結果は、 parameter_values[i] として束縛されたパラメータで評価された circuits[i] に対応する。

レイズ

ValueError - 無効な引数が与えられている。

戻りの型

T

set_options

set_options(**fields)

GitHub

推定値のオプション値を設定する。

パラメーター

** fields - オプションを更新するフィールド

このページは役に立ちましたか?
バグや誤字の報告、またはコンテンツの要求はGitHubで行ってください。